summaryrefslogtreecommitdiffstats
path: root/roles/nvidia_gtx1060/tasks/install-archlinux.yml
blob: 0a8565eadc69a622b7e9b46e7d134f9686cac071 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- name: "Install libva NVIDIA driver"
  become: true
  ansible.builtin.package:
    name: "{{ nvidia_gtx1060_packages }}"
    state: "present"

- 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: "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
  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"