Skip to content

Commit da31591

Browse files
committed
try improving package install selection
1 parent c514556 commit da31591

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

ansible/roles/cuda/tasks/install.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,28 @@
3030
changed_when: "'Nothing to do' not in _cuda_driver_module_enable.stdout"
3131

3232
- name: Read module info for list of packages
33+
# Even a single version of the module stream contains multiple package versions
34+
# so need to find the ones we want.
35+
# The dnf .. command returns a list of lines like
36+
# ' : libnvidia-cfg-3:570.133.20-1.el9.x86_64'
37+
# Some are duplicated for arch x86_64/.i684
38+
# Some don't have arch or distro, or have .noarch
39+
# so want to get full package name without any suffixes so we can use
40+
# {{ | unique }} later to get the actual packages to dnf install.
41+
# The literal dot after the vesion is important so we don't get
42+
# e.g. -10. when we want -1.
43+
# So from the example line above we extract
44+
# ' libnvidia-cfg-3:570.133.20-1.'
3345
ansible.builtin.shell:
3446
cmd: >-
3547
dnf module info nvidia-driver:{{ cuda_nvidia_driver_stream }} |
36-
grep -F {{ cuda_nvidia_driver_version }}.el{{ ansible_distribution_major_version }}.{{ ansible_architecture }}
48+
grep -o '[^:]*:{{ cuda_nvidia_driver_version }}\.'
3749
changed_when: false
3850
register: _cuda_driver_module_packages
39-
# returns a list of lines like ' : libnvidia-cfg-3:570.133.20-1.el9.x86_64'
40-
51+
4152
- name: Install nvidia driver packages
42-
# its not possible to install a version of a module
43-
# apparently this is the best way of approximating that
44-
# but it is more idempotent than the module install anyway
4553
ansible.builtin.dnf:
46-
name: "{{ _cuda_driver_module_packages.stdout_lines | map('trim', ': ') }}"
54+
name: "{{ _cuda_driver_module_packages.stdout_lines | map('trim', ' .') | unique }}"
4755
register: _cuda_driver_install
4856

4957
- name: Check kernel has not been modified

0 commit comments

Comments
 (0)