|
30 | 30 | changed_when: "'Nothing to do' not in _cuda_driver_module_enable.stdout"
|
31 | 31 |
|
32 | 32 | - 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.' |
33 | 45 | ansible.builtin.shell:
|
34 | 46 | cmd: >-
|
35 | 47 | 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 }}\.' |
37 | 49 | changed_when: false
|
38 | 50 | register: _cuda_driver_module_packages
|
39 |
| - # returns a list of lines like ' : libnvidia-cfg-3:570.133.20-1.el9.x86_64' |
40 |
| - |
| 51 | + |
41 | 52 | - 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 |
45 | 53 | ansible.builtin.dnf:
|
46 |
| - name: "{{ _cuda_driver_module_packages.stdout_lines | map('trim', ': ') }}" |
| 54 | + name: "{{ _cuda_driver_module_packages.stdout_lines | map('trim', ' .') | unique }}" |
47 | 55 | register: _cuda_driver_install
|
48 | 56 |
|
49 | 57 | - name: Check kernel has not been modified
|
|
0 commit comments