From 68cffed89beab7c410ccf3552e63bb509cc9b4c5 Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Mon, 16 Nov 2020 18:23:03 +0000 Subject: [PATCH 1/6] Ubuntu: Use NVIDIA server drivers from Canonical - Add support for using the NVIDIA headless server packages from the upstream Canonical repos - Keep support for using the CUDA repository instead, but make non-default --- defaults/main.yml | 21 ++++++++++++++++-- tasks/install-ubuntu-cuda-repo.yml | 35 ++++++++++++++++++++++++++++++ tasks/install-ubuntu.yml | 28 ++++-------------------- tasks/main.yml | 8 +++++-- 4 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 tasks/install-ubuntu-cuda-repo.yml diff --git a/defaults/main.yml b/defaults/main.yml index 528d531..37dc3b8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,13 +5,30 @@ nvidia_driver_skip_reboot: no nvidia_driver_module_file: /etc/modprobe.d/nvidia.conf nvidia_driver_module_params: '' -# RedHat family +############################################################################## +# RedHat family # +############################################################################## nvidia_driver_rhel_epel_repo_baseurl: "https://download.fedoraproject.org/pub/epel/$releasever/$basearch/" nvidia_driver_rhel_epel_repo_gpgkey: "https://epel.mirror.constant.com//RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}" nvidia_driver_rhel_cuda_repo_baseurl: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/" nvidia_driver_rhel_cuda_repo_gpgkey: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/7fa2af80.pub" -# Ubuntu + +############################################################################## +# Ubuntu # +############################################################################## + +# Determine if we should install from CUDA repo instead of Canonical repos +nvidia_driver_ubuntu_install_from_cuda_repo: no + +# Installing with Canonical repositories +nvidia_driver_ubuntu_branch: "450" +nvidia_driver_ubuntu_packages: +- "nvidia-headless-{{ nvidia_driver_ubuntu_branch }}-server" +- "nvidia-utils-{{ nvidia_driver_ubuntu_branch }}-server" + +# Installing with CUDA repositories nvidia_driver_ubuntu_cuda_repo_gpgkey_url: "https://developer.download.nvidia.com/compute/cuda/repos/{{ _ubuntu_repo_dir }}/7fa2af80.pub" nvidia_driver_ubuntu_cuda_repo_gpgkey_id: "7fa2af80" nvidia_driver_ubuntu_cuda_repo_baseurl: "http://developer.download.nvidia.com/compute/cuda/repos/{{ _ubuntu_repo_dir }}" +nvidia_driver_ubuntu_cuda_package: "cuda-drivers" diff --git a/tasks/install-ubuntu-cuda-repo.yml b/tasks/install-ubuntu-cuda-repo.yml new file mode 100644 index 0000000..7aab994 --- /dev/null +++ b/tasks/install-ubuntu-cuda-repo.yml @@ -0,0 +1,35 @@ +--- +- name: remove ppa + apt_repository: + repo: ppa:graphics-drivers/ppa + state: absent + +- name: add pin file + copy: + src: "cuda-ubuntu.pin" + dest: "/etc/apt/preferences.d/cuda-repository-pin-600" + owner: "root" + group: "root" + mode: "0644" + +- name: add key + apt_key: + url: "{{ nvidia_driver_ubuntu_cuda_repo_gpgkey_url }}" + id: "{{ nvidia_driver_ubuntu_cuda_repo_gpgkey_id }}" + environment: "{{proxy_env if proxy_env is defined else {}}}" + + +- name: add repo + apt_repository: + repo: "deb {{ nvidia_driver_ubuntu_cuda_repo_baseurl }} /" + update_cache: yes + environment: "{{proxy_env if proxy_env is defined else {}}}" + +- name: install driver packages + apt: + name: "{{ nvidia_driver_package_version | ternary(nvidia_driver_ubuntu_cuda_package+'='+nvidia_driver_package_version, nvidia_driver_ubuntu_cuda_package) }}" + state: "{{ nvidia_driver_package_state }}" + autoremove: "{{ nvidia_driver_package_state == 'absent' }}" + purge: "{{ nvidia_driver_package_state == 'absent' }}" + register: install_driver + environment: "{{proxy_env if proxy_env is defined else {}}}" diff --git a/tasks/install-ubuntu.yml b/tasks/install-ubuntu.yml index 7bc40b4..7aa876c 100644 --- a/tasks/install-ubuntu.yml +++ b/tasks/install-ubuntu.yml @@ -4,32 +4,12 @@ repo: ppa:graphics-drivers/ppa state: absent -- name: add pin file - copy: - src: "cuda-ubuntu.pin" - dest: "/etc/apt/preferences.d/cuda-repository-pin-600" - owner: "root" - group: "root" - mode: "0644" - -- name: add key - apt_key: - url: "{{ nvidia_driver_ubuntu_cuda_repo_gpgkey_url }}" - id: "{{ nvidia_driver_ubuntu_cuda_repo_gpgkey_id }}" - environment: "{{proxy_env if proxy_env is defined else {}}}" - - -- name: add repo - apt_repository: - repo: "deb {{ nvidia_driver_ubuntu_cuda_repo_baseurl }} /" - update_cache: yes - environment: "{{proxy_env if proxy_env is defined else {}}}" - - name: install driver packages apt: - name: "{{ nvidia_driver_package_version | ternary('cuda-drivers='+nvidia_driver_package_version, 'cuda-drivers') }}" - state: "{{ nvidia_driver_package_state }}" + name: "{{ nvidia_driver_package_version | ternary(item+'='+nvidia_driver_package_version, item) }}" + state: "{{ nvidia_driver_package_version }}" autoremove: "{{ nvidia_driver_package_state == 'absent' }}" purge: "{{ nvidia_driver_package_state == 'absent' }}" + with_items: "{{ nvidia_driver_ubuntu_packages }}" register: install_driver - environment: "{{proxy_env if proxy_env is defined else {}}}" + envrionment: "{{proxy_env if proxy_env is defined else {}}}" diff --git a/tasks/main.yml b/tasks/main.yml index 9ab9c4f..d33f672 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,9 +5,13 @@ state: absent ignore_errors: true -- name: ubuntu install tasks +- name: ubuntu install tasks (canonical repos) include_tasks: install-ubuntu.yml - when: ansible_distribution == 'Ubuntu' + when: ansible_distribution == 'Ubuntu' and (not nvidia_driver_ubuntu_install_from_cuda_repo) + +- name: ubuntu install tasks (CUDA repo) + include_tasks: install-ubuntu-cuda-repo.yml + when: ansible_distribution == 'Ubuntu' and nvidia_driver_ubuntu_install_from_cuda_repo - name: redhat family install tasks include_tasks: install-redhat.yml From 4fcec816f5635440646bcc40e4192f2b9b245f15 Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Mon, 16 Nov 2020 18:25:54 +0000 Subject: [PATCH 2/6] add a note on distro support --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index adf52b1..f3fcdeb 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ $ ansible-galaxy install nvidia.nvidia_driver Currently, this role supports the following Linux distributions: * NVIDIA DGX OS 4 +* NVIDIA DGX OS 5 * Ubuntu 18.04 LTS +* Ubuntu 20.04 LTS * CentOS 7 * Red Hat Enterprise Linux 7 From 9496992a2116148a7ed30c1761e3e0c282101877 Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Mon, 16 Nov 2020 18:45:02 +0000 Subject: [PATCH 3/6] typo fix --- tasks/install-ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/install-ubuntu.yml b/tasks/install-ubuntu.yml index 7aa876c..fb6fc74 100644 --- a/tasks/install-ubuntu.yml +++ b/tasks/install-ubuntu.yml @@ -12,4 +12,4 @@ purge: "{{ nvidia_driver_package_state == 'absent' }}" with_items: "{{ nvidia_driver_ubuntu_packages }}" register: install_driver - envrionment: "{{proxy_env if proxy_env is defined else {}}}" + environment: "{{proxy_env if proxy_env is defined else {}}}" From 4138b45d40216468e7df67ae1d2ac0d9d58c5546 Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Mon, 16 Nov 2020 18:46:29 +0000 Subject: [PATCH 4/6] use correct var --- tasks/install-ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/install-ubuntu.yml b/tasks/install-ubuntu.yml index fb6fc74..bcd0a39 100644 --- a/tasks/install-ubuntu.yml +++ b/tasks/install-ubuntu.yml @@ -7,7 +7,7 @@ - name: install driver packages apt: name: "{{ nvidia_driver_package_version | ternary(item+'='+nvidia_driver_package_version, item) }}" - state: "{{ nvidia_driver_package_version }}" + state: "{{ nvidia_driver_package_state }}" autoremove: "{{ nvidia_driver_package_state == 'absent' }}" purge: "{{ nvidia_driver_package_state == 'absent' }}" with_items: "{{ nvidia_driver_ubuntu_packages }}" From a7ea9206a5e7b07550bc54ea1c625215fec9e22d Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Mon, 16 Nov 2020 18:54:36 +0000 Subject: [PATCH 5/6] Add notes on install process to README --- README.md | 7 +++++++ defaults/.main.yml.swp | Bin 0 -> 12288 bytes 2 files changed, 7 insertions(+) create mode 100644 defaults/.main.yml.swp diff --git a/README.md b/README.md index f3fcdeb..8b8279a 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,19 @@ $ ansible-galaxy install nvidia.nvidia_driver ### Ubuntu specific variables +For Ubuntu installs, you have the choice of installing from the Canonical repositories and the NVIDIA CUDA repositories. + +By default, the Canonical repositories will be used, and the driver installed will be the headless server driver. | Variable | Default value | Description | | -------- | ------------- | ----------- | +| `nvidia_driver_ubuntu_install_from_cuda_repo` | `no` | Flag whether to use the CUDA repo | +| `nvidia_driver_ubuntu_branch` | `450` | Driver branch to use for the install | +| `nvidia_driver_ubuntu_packages` | `["nvidia-headless-450-server", "nvidia-headless-450-utils"]` | Package names to install from Canonical repo | | `nvidia_driver_ubuntu_cuda_repo_baseurl` | `"http://developer.download.nvidia.com/compute/cuda/repos/{{ _ubuntu_repo_dir }}"` | Base URL to use for CUDA repo | | `nvidia_driver_ubuntu_cuda_repo_gpgkey_url` | `"https://developer.download.nvidia.com/compute/cuda/repos/{{ _ubuntu_repo_dir }}/7fa2af80.pub"` | GPG key for the CUDA repo | | `nvidia_driver_ubuntu_cuda_repo_gpgkey_id` | `"7fa2af80"` | GPG key ID for the CUDA repo | +| `nvidia_driver_ubuntu_cuda_package` | `"cuda-drivers"` | Package name to install from CUDA repo | ## Example playbook diff --git a/defaults/.main.yml.swp b/defaults/.main.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..291af5d1fe031a161bc0d2d3a446f83600afebf3 GIT binary patch literal 12288 zcmeI2&x;&I6vrzH{)n!Mf~N@OY#^uU+N=@7fQOK*n-~L2V8xu8>aN!_wNqWyR#oq^ zge3ohc=zsEPhLe31W)2g{X0ZYzWy<6rk!1X%_Z^*zSHzn*Q-~bdas&cUbgk&tvmc` zvc<5y!r0GWf06$1%==GoJz`8M$eq>Y5g-CY;QvM-R_7T0)Mroi3mf&>Y5g-CY;0Yuk6=UB%%h>!mbRPfzU;O_6>1D>gLVb#gsCQ9spe~@ke+mD~ zM+ww78;o5;efJ_`H&MH&_fWsSz}V-gd#I048>nB-V|@YYOVlT*k5N}pzdz5|Z>S$p zw^6U7K0|*RpAH(os1X4oKm>>Y5g-CjDuJ%FFYQYE(mJbctkb+!GOc7jms6PVQFGfD z|Ai4deT0X~rI`#+dxOJfF;)|S<${M`Tm?Q+?#LP^RnnPAa#speRYwrb9HKE0#Qpnx z;Ye#yY0n=#_{)i>)pQQWsa81kJB8eq#nr99JLtsWus)B)!i%J;vk}|mw`_>g7;UHg z2&*jl_5B;yc)MmDo!1Z;8}m_LY*|Nb!Wdbsk8# zbMyfaCabr+a{*yrc^f&eSe>+3ru8(n_Kpqq&CkG`uuZ#s>GSko zhka}Gu{0e7{qklHJXk&|*5|@7>)UCe!qvBq{%PS&S5j*4oyRk&i9{RQ!%5uTyEES1 z+a2HDxi{X~+xei$$G$Q;RXRkkGt5(G(^4KdpJE~gyjyWv4P02U^2OO$fO1||-W@<5 z6X&M_PY=j*n0sq&7}a+{-IS3Rvef4Izs2_Yqk1`{N~dZA z__Fe{3=@9o(je&j{z4mklL?5qz;BRl28j}#sbG00jJ6U literal 0 HcmV?d00001 From 6cb674908f6bac6ae43736a06167ff437653595f Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Mon, 16 Nov 2020 19:50:14 +0000 Subject: [PATCH 6/6] include galaxy metadata for 20.04 support --- defaults/.main.yml.swp | Bin 12288 -> 0 bytes meta/main.yml | 1 + 2 files changed, 1 insertion(+) delete mode 100644 defaults/.main.yml.swp diff --git a/defaults/.main.yml.swp b/defaults/.main.yml.swp deleted file mode 100644 index 291af5d1fe031a161bc0d2d3a446f83600afebf3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&x;&I6vrzH{)n!Mf~N@OY#^uU+N=@7fQOK*n-~L2V8xu8>aN!_wNqWyR#oq^ zge3ohc=zsEPhLe31W)2g{X0ZYzWy<6rk!1X%_Z^*zSHzn*Q-~bdas&cUbgk&tvmc` zvc<5y!r0GWf06$1%==GoJz`8M$eq>Y5g-CY;QvM-R_7T0)Mroi3mf&>Y5g-CY;0Yuk6=UB%%h>!mbRPfzU;O_6>1D>gLVb#gsCQ9spe~@ke+mD~ zM+ww78;o5;efJ_`H&MH&_fWsSz}V-gd#I048>nB-V|@YYOVlT*k5N}pzdz5|Z>S$p zw^6U7K0|*RpAH(os1X4oKm>>Y5g-CjDuJ%FFYQYE(mJbctkb+!GOc7jms6PVQFGfD z|Ai4deT0X~rI`#+dxOJfF;)|S<${M`Tm?Q+?#LP^RnnPAa#speRYwrb9HKE0#Qpnx z;Ye#yY0n=#_{)i>)pQQWsa81kJB8eq#nr99JLtsWus)B)!i%J;vk}|mw`_>g7;UHg z2&*jl_5B;yc)MmDo!1Z;8}m_LY*|Nb!Wdbsk8# zbMyfaCabr+a{*yrc^f&eSe>+3ru8(n_Kpqq&CkG`uuZ#s>GSko zhka}Gu{0e7{qklHJXk&|*5|@7>)UCe!qvBq{%PS&S5j*4oyRk&i9{RQ!%5uTyEES1 z+a2HDxi{X~+xei$$G$Q;RXRkkGt5(G(^4KdpJE~gyjyWv4P02U^2OO$fO1||-W@<5 z6X&M_PY=j*n0sq&7}a+{-IS3Rvef4Izs2_Yqk1`{N~dZA z__Fe{3=@9o(je&j{z4mklL?5qz;BRl28j}#sbG00jJ6U diff --git a/meta/main.yml b/meta/main.yml index 3a9017a..da7c9f0 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,6 +11,7 @@ galaxy_info: versions: - 'xenial' - 'bionic' + - 'focal' - name: EL versions: - '7'