feat(packer): Migrate 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: Get vfio-pci With WC Patcher
10   ansible.builtin.get_url:
11     url: "https://github.com/amzn/amzn-drivers/raw/master/userspace/dpdk/enav2-vfio-patch/get-vfio-with-wc.sh"
12     dest: "/opt/get-vfio-with-wc.sh"
13     mode: "744"
14   tags:
15     - aws-vfio-patch
16
17 - name: Create vfio-pci Patch Directory
18   ansible.builtin.file:
19     path: "/opt/patches/"
20     state: "directory"
21   tags:
22     - aws-vfio-patch
23
24 - name: Get vfio-pci WC Patch >=5.15
25   ansible.builtin.get_url:
26     url: "https://github.com/amzn/amzn-drivers/raw/master/userspace/dpdk/enav2-vfio-patch/patches/linux-5.15-vfio-wc.patch"
27     dest: "/opt/patches/linux-5.15-vfio-wc.patch"
28     mode: "744"
29   tags:
30     - aws-vfio-patch
31
32 - name: Patch WC Patch Script
33   ansible.builtin.lineinfile:
34     path: "/opt/get-vfio-with-wc.sh"
35     regexp: '^  rm -f linux-'
36     line: "     rm -f linux-*.dsc linux-*.gz linux-*.xz"
37   tags:
38     - aws-vfio-patch
39
40 - name: Patch WC Patch Script II
41   ansible.builtin.replace:
42     path: "/opt/get-vfio-with-wc.sh"
43     regexp: 'linux-image-'
44     replace: 'linux-image-unsigned-'
45   tags:
46     - aws-vfio-patch
47
48 #- name: Compile vfio-pci With WC Patch
49 #  ansible.builtin.shell: "/bin/bash /opt/get-vfio-with-wc.sh"
50 #  environment:
51 #    DEBIAN_FRONTEND: "noninteractive"
52 #    TERM: "vt100"
53 #  tags:
54 #    - aws-vfio-patch
55
56 - name: Load Kernel Modules By Default
57   ansible.builtin.lineinfile:
58     path: "/etc/modules"
59     state: "present"
60     line: "{{ item }}"
61   with_items:
62     - "vfio-pci"
63     - "igb_uio"
64   tags:
65     - aws-load-kernel-modules
66
67 - name: Add Kernel Modules Options (igb_uio)
68   ansible.builtin.lineinfile:
69     path: "/etc/modprobe.d/igb_uio.conf"
70     state: "present"
71     line: "{{ item }}"
72     create: "yes"
73   with_items:
74     - "options igb_uio wc_activate=1"
75   tags:
76     - aws-load-kernel-modules
77
78 - name: Add Kernel Modules Options (vfio-pci)
79   ansible.builtin.lineinfile:
80     path: "/etc/modprobe.d/vfio-noiommu.conf"
81     state: "present"
82     line: "{{ item }}"
83     create: "yes"
84   with_items:
85     - "options vfio enable_unsafe_noiommu_mode=1"
86   tags:
87     - aws-load-kernel-modules
88
89 - name: Reload systemd-modules
90   ansible.builtin.systemd:
91     name: "systemd-modules-load"
92     state: "restarted"
93   tags:
94     - aws-reload-systemd-modules
95
96 - name: Adjust nr_hugepages
97   ansible.builtin.sysctl:
98     name: "vm.nr_hugepages"
99     value: "8192"
100     state: "present"
101     sysctl_file: "/etc/sysctl.d/90-csit.conf"
102     reload: "yes"
103   tags:
104     - aws-set-hugepages
105
106 - name: Shutdown host with delay
107   ansible.builtin.command: "/sbin/shutdown -P +720"
108   tags:
109     - aws-set-self-terminate