--- - name: "Install NVIDIA driver from AUR" become: true become_user: "aur_builder" kewlfft.aur.aur: name: "{{ nvidia_gtx1060_aur_packages }}" state: "present" use: "yay" - name: "Install libva NVIDIA driver" become: true ansible.builtin.package: name: "{{ nvidia_gtx1060_packages }}" state: "present" - name: "Configure NVIDIA DRM kernel mode setting" become: true ansible.builtin.template: src: "nvidia.conf.j2" dest: "/etc/modprobe.d/nvidia.conf" mode: "0644" notify: - "Rebuild initramfs" tags: # Since the /etc/mkinitcpio isn't available on the docker container # Ignore this for testing, - "molecule-notest" - name: "Get current mkinitcpio MODULES" become: true ansible.builtin.shell: | set -euo pipefail grep '^MODULES=' /etc/mkinitcpio.conf | sed 's/MODULES=(\(.*\))/\1/' # noqa var-naming[no-role-prefix] as it describes the current kernel modules and not the nvidia modules register: "current_kernel_modules" changed_when: false args: executable: /bin/bash tags: # Since the /etc/mkinitcpio isn't available on the docker container # Ignore this for testing, - "molecule-notest" - name: "Add NVIDIA modules to mkinitcpio" become: true vars: existing_modules: "{{ current_kernel_modules.stdout.split() | reject('in', nvidia_gtx1060_modules) | list }}" all_modules: "{{ existing_modules + nvidia_gtx1060_modules }}" ansible.builtin.lineinfile: path: "/etc/mkinitcpio.conf" regexp: "^MODULES=\\(.*\\)" line: "MODULES=({{ all_modules | join(' ') }})" notify: - "Rebuild initramfs" tags: # Since the /etc/mkinitcpio isn't available on the docker container # Ignore this for testing, - "molecule-notest"