File tree 3 files changed +57
-2
lines changed
3 files changed +57
-2
lines changed Original file line number Diff line number Diff line change 20
20
become: true
21
21
22
22
```
23
+
24
+ Or if you want the node to reboot automatically
25
+
26
+ ```
27
+ ---
28
+ - name: Enable IOMMU
29
+ hosts: iommu
30
+ tasks:
31
+ - import_role:
32
+ name: stackhpc.linux.iommu
33
+ handlers:
34
+ - name: reboot
35
+ reboot:
36
+ become: true
37
+
38
+ ```
Original file line number Diff line number Diff line change
1
+ ---
2
+ - name : Regenerate initramfs
3
+ ansible.builtin.shell : |-
4
+ #!/bin/bash
5
+ set -eux
6
+ dracut -v -f /boot/initramfs-$(uname -r).img $(uname -r)
7
+ become : true
8
+ changed_when : true
Original file line number Diff line number Diff line change 1
1
---
2
+ - name : Template dracut config for vfio
3
+ ansible.builtin.blockinfile :
4
+ path : /etc/dracut.conf.d/gpu-vfio.conf
5
+ block : |
6
+ add_drivers+="vfio vfio_iommu_type1 vfio_pci vfio_virqfd"
7
+ owner : root
8
+ group : root
9
+ mode : " 0660"
10
+ create : true
11
+ become : true
12
+ when : iommu_vfio_pci_ids is defined
13
+ notify :
14
+ - Regenerate initramfs
15
+ - reboot
16
+
17
+ - name : Add vfio to modules-load.d
18
+ ansible.builtin.blockinfile :
19
+ path : /etc/modules-load.d/vfio.conf
20
+ block : |
21
+ vfio
22
+ vfio_iommu_type1
23
+ vfio_pci
24
+ vfio_virqfd
25
+ owner : root
26
+ group : root
27
+ mode : " 0664"
28
+ create : true
29
+ become : true
30
+ when : iommu_vfio_pci_ids is defined
31
+ notify : reboot
32
+
2
33
- name : Add iommu to kernel command line (Intel)
3
34
ansible.builtin.include_role :
4
35
name : stackhpc.linux.grubcmdline
5
36
vars :
6
- kernel_cmdline : # noqa: var-naming[no-role-prefix]
7
- - intel_iommu=on
37
+ kernel_cmdline : " {{ ['intel_iommu=on'] + (['vfio-pci.ids=' + iommu_vfio_pci_ids] if iommu_vfio_pci_ids is defined else []) }}" # noqa: var-naming[no-role-prefix]
8
38
kernel_cmdline_remove : # noqa: var-naming[no-role-prefix]
9
39
- ^intel_iommu=
40
+ - ^vfio-pci\.ids=
10
41
when : ansible_facts.processor | select('search', 'Intel') | list | length > 0
11
42
12
43
- name : Set iommu=pt
You can’t perform that action at this time.
0 commit comments