fix(packer): AWS images
[csit.git] / fdio.infra.ansible / roles / aws / tasks / main.yaml
1 ---
2 # file: roles/aws/tasks/main.yaml
3
4 - name: Edit repositories
5   include_tasks: "{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml"
6   tags:
7     - aws-edit-repo
8
9 - name: Prerequisites
10   ansible.builtin.package:
11     name: "{{ packages | flatten(levels=1) }}"
12     state: "latest"
13   tags:
14     - aws-inst-prerequisites
15
16 - name: Switch Kernel At Boot
17   ansible.builtin.lineinfile:
18     path: "/etc/default/grub"
19     state: "present"
20     line: "GRUB_DEFAULT=\"1>2\""
21   notify:
22     - "Update GRUB"
23   tags:
24     - perf-conf-grub
25
26 - meta: flush_handlers
27
28 - name: Load Kernel Modules By Default
29   ansible.builtin.lineinfile:
30     path: "/etc/modules"
31     state: "present"
32     line: "{{ item }}"
33   with_items:
34     - "igb_uio"
35     - "vfio-pci"
36   notify:
37     - "Reboot Server"
38   tags:
39     - aws-load-kernel-modules
40
41 - name: Add Kernel Modules Options (igb_uio)
42   ansible.builtin.lineinfile:
43     path: "/etc/modprobe.d/igb_uio.conf"
44     state: "present"
45     line: "{{ item }}"
46     create: "yes"
47   with_items:
48     - "options igb_uio wc_activate=1"
49   notify:
50     - "Reboot Server"
51   tags:
52     - aws-load-kernel-modules
53
54 - name: Add Kernel Modules Options (vfio-pci)
55   ansible.builtin.lineinfile:
56     path: "/etc/modprobe.d/vfio-noiommu.conf"
57     state: "present"
58     line: "{{ item }}"
59     create: "yes"
60   with_items:
61     - "options vfio enable_unsafe_noiommu_mode=1"
62   notify:
63     - "Reboot Server"
64   tags:
65     - aws-load-kernel-modules
66
67 - meta: flush_handlers
68
69 #- name: Get vfio-pci With WC Patcher
70 #  ansible.builtin.get_url:
71 #    url: "https://github.com/amzn/amzn-drivers/raw/master/userspace/dpdk/enav2-vfio-patch/get-vfio-with-wc.sh"
72 #    dest: "/opt/get-vfio-with-wc.sh"
73 #    mode: 0744
74 #  tags:
75 #    - aws-vfio-patch
76
77 - name: Create vfio-pci Patch Directory
78   ansible.builtin.file:
79     path: "/opt/patches/"
80     state: "directory"
81   tags:
82     - aws-vfio-patch
83
84 - name: Get vfio-pci WC Patch
85   ansible.builtin.get_url:
86     url: "https://github.com/amzn/amzn-drivers/raw/master/userspace/dpdk/enav2-vfio-patch/patches/{{ item }}"
87     dest: "/opt/patches/{{ item }}"
88     mode: 0744
89   with_items:
90     - "linux-4.10-vfio-wc.patch"
91     - "linux-5.8-vfio-wc.patch"
92     - "linux-5.15-vfio-wc.patch"
93   tags:
94     - aws-vfio-patch
95
96 - name: Copy vfio-pci WC Patch
97   ansible.builtin.copy:
98     src: "files/get-vfio-with-wc.sh"
99     dest: "/opt"
100     mode: 0744
101   tags:
102     - aws-vfio-patch
103
104 - name: Compile vfio-pci With WC Patch
105   ansible.builtin.shell: "/bin/bash /opt/get-vfio-with-wc.sh"
106   environment:
107     DEBIAN_FRONTEND: "noninteractive"
108     TERM: "vt100"
109   tags:
110     - aws-vfio-patch
111
112 - name: Reload systemd-modules
113   ansible.builtin.systemd:
114     name: "systemd-modules-load"
115     state: "restarted"
116   tags:
117     - aws-reload-systemd-modules
118
119 - name: Adjust nr_hugepages
120   ansible.builtin.sysctl:
121     name: "vm.nr_hugepages"
122     value: "8192"
123     state: "present"
124     sysctl_file: "/etc/sysctl.d/90-csit.conf"
125     reload: true
126   tags:
127     - aws-set-hugepages
128
129 - name: Shutdown host with delay
130   ansible.builtin.command: "/sbin/shutdown -P +720"
131   tags:
132     - aws-set-self-terminate