Skip to content

Commit

Permalink
Allow specifying the variant for the ubuntu drivers
Browse files Browse the repository at this point in the history
Signed-off-by: guenthgr <[email protected]>
  • Loading branch information
guenthgr committed Aug 16, 2022
1 parent 35a769d commit 7b9fb62
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.retry
.idea/
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,37 @@ $ ansible-galaxy install nvidia.nvidia_driver
## Role variables


| Variable | Default value | Description |
| -------- | ------------- | ----------- |
| `nvidia_driver_package_state` | `"present"` | Package state for NVIDIA driver packages |
| `nvidia_driver_package_version` | `""` | Package version to install. Note that this should match the actual version of the deb or RPM package to be installed. |
| `nvidia_driver_persistence_mode_on` | `yes` | Whether to enable persistence mode (boolean) |
| `nvidia_driver_skip_reboot` | `no` | Whether to skip rebooting the node during the install |
| `nvidia_driver_module_file` | `"/etc/modprobe.d/nvidia.conf"` | Filename to use for NVIDIA driver parameters |
| `nvidia_driver_module_params` | `""` | Parameters to pass to the NVIDIA driver |
| `nvidia_driver_branch` | `"515"` | Default driver branch to install |
| Variable | Default value | Description |
|-------------------------------------|---------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `nvidia_driver_package_state` | `"present"` | Package state for NVIDIA driver packages |
| `nvidia_driver_package_version` | `""` | Package version to install. Note that this should match the actual version of the deb or RPM package to be installed. |
| `nvidia_driver_persistence_mode_on` | `yes` | Whether to enable persistence mode (boolean) |
| `nvidia_driver_skip_reboot` | `no` | Whether to skip rebooting the node during the install |
| `nvidia_driver_module_file` | `"/etc/modprobe.d/nvidia.conf"` | Filename to use for NVIDIA driver parameters |
| `nvidia_driver_module_params` | `""` | Parameters to pass to the NVIDIA driver |
| `nvidia_driver_branch` | `"515"` | Default driver branch to install |

### Red Hat specific variables


| Variable | Default value | Description |
| -------- | ------------- | ----------- |
| `epel_package` | `"https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"` | Package to install to enable EPEL |
| `nvidia_driver_rhel_cuda_repo_baseurl` | `"https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/"` | Base URL to use for CUDA repo |
| `nvidia_driver_rhel_cuda_repo_gpgkey` | `"https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/7fa2af80.pub"` | GPG key for the CUDA repo |
| Variable | Default value | Description |
|----------------------------------------|-------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| `epel_package` | `"https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"` | Package to install to enable EPEL |
| `nvidia_driver_rhel_cuda_repo_baseurl` | `"https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/"` | Base URL to use for CUDA repo |
| `nvidia_driver_rhel_cuda_repo_gpgkey` | `"https://developer.download.nvidia.com/compute/cuda/repos/{{ _rhel_repo_dir }}/7fa2af80.pub"` | GPG key for the CUDA repo |

### 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_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_package` | `"cuda-drivers"` | Package name to install from CUDA repo |
| Variable | Default value | Description |
|-----------------------------------------------|------------------------------------------------------------------------------------|------------------------------------------------------|
| `nvidia_driver_ubuntu_install_from_cuda_repo` | `no` | Flag whether to use the CUDA 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_package` | `"cuda-drivers"` | Package name to install from CUDA repo |
| `nvidia_driver_ubuntu_packages_suffix` | `"-server"` | The suffix added to the apt packages when installing |

## Example playbook

Expand Down
10 changes: 6 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ nvidia_driver_ubuntu_branch: "{{ nvidia_driver_branch }}"
# Determine if we should install from CUDA repo instead of Canonical repos
nvidia_driver_ubuntu_install_from_cuda_repo: no

nvidia_driver_ubuntu_packages_suffix: "-server"

# Installing with Canonical repositories
nvidia_driver_ubuntu_packages:
- "nvidia-headless-{{ nvidia_driver_ubuntu_branch }}-server"
- "nvidia-utils-{{ nvidia_driver_ubuntu_branch }}-server"
- "nvidia-headless-no-dkms-{{ nvidia_driver_ubuntu_branch }}-server"
- "nvidia-kernel-source-{{ nvidia_driver_ubuntu_branch }}-server"
- "nvidia-headless-{{ nvidia_driver_ubuntu_branch }}{{ nvidia_driver_ubuntu_packages_suffix }}"
- "nvidia-utils-{{ nvidia_driver_ubuntu_branch }}{{ nvidia_driver_ubuntu_packages_suffix }}"
- "nvidia-headless-no-dkms-{{ nvidia_driver_ubuntu_branch }}{{ nvidia_driver_ubuntu_packages_suffix }}"
- "nvidia-kernel-source-{{ nvidia_driver_ubuntu_branch }}{{ nvidia_driver_ubuntu_packages_suffix }}"

# Installing with CUDA repositories
old_nvidia_driver_ubuntu_cuda_repo_gpgkey_id: "7fa2af80"
Expand Down
16 changes: 15 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ platforms:
- cuda_repo
- ubuntu

- name: ubuntu-2004-canonical
- name: ubuntu-2004-canonical-server
image: geerlingguy/docker-ubuntu2004-ansible
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
Expand All @@ -38,6 +38,18 @@ platforms:
- canonical_repo
- ubuntu

- name: ubuntu-2004-canonical-noserver
image: geerlingguy/docker-ubuntu2004-ansible
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: /sbin/init
pre_build_image: true
privileged: true
groups:
- canonical_repo
- canonical_repo_noserver
- ubuntu

- name: ubuntu-2004-cuda
image: geerlingguy/docker-ubuntu2004-ansible
volumes:
Expand Down Expand Up @@ -97,6 +109,8 @@ provisioner:
nvidia_driver_skip_reboot: true
canonical_repo:
nvidia_driver_ubuntu_install_from_cuda_repo: false
canonical_repo_noserver:
nvidia_driver_ubuntu_packages_suffix: ""
cuda_repo:
nvidia_driver_ubuntu_install_from_cuda_repo: true
verifier:
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
state: "{{ nvidia_driver_package_state }}"
autoremove: "{{ nvidia_driver_package_state == 'absent' }}"
purge: "{{ nvidia_driver_package_state == 'absent' }}"
with_items: "{{ nvidia_driver_ubuntu_packages }}"
loop: "{{ nvidia_driver_ubuntu_packages }}"
register: install_driver
environment: "{{proxy_env if proxy_env is defined else {}}}"

0 comments on commit 7b9fb62

Please sign in to comment.