fix(ansible): Compatibility improvements
[csit.git] / fdio.infra.ansible / roles / trex / tasks / deploy_block.yaml
1 ---
2 # file: roles/trex/tasks/deploy_block.yaml
3
4 - name: Get Release {{ item }}
5   ansible.builtin.get_url:
6     url: "{{ trex_url }}/v{{ item }}.tar.gz"
7     dest: "{{ trex_target_dir }}/trex-core-{{ item }}.tar.gz"
8     validate_certs: false
9     mode: 0644
10   register: trex_downloaded
11
12 - name: Create Directory {{ item }}
13   ansible.builtin.file:
14     path: "{{ trex_target_dir }}/trex-core-{{ item }}"
15     state: "directory"
16
17 - name: Extract Release {{ item }}
18   ansible.builtin.unarchive:
19     remote_src: true
20     src: "{{ trex_target_dir }}/trex-core-{{ item }}.tar.gz"
21     dest: "{{ trex_target_dir }}/"
22     creates: "{{ trex_target_dir }}/trex-core-{{ item }}/linux_dpdk/"
23   register: trex_extracted
24
25 - name: Patch Azure
26   ansible.builtin.patch:
27     src: "files/t-rex.patch"
28     basedir: "{{ trex_target_dir }}/trex-core-{{ item }}"
29     strip: 1
30   when:
31     - azure is defined and item == "2.73"
32
33 - name: Reset gcc-9
34   ansible.builtin.command: "update-alternatives --remove-all gcc"
35   when: trex_extracted.changed
36
37 - name: Reset g++-9
38   ansible.builtin.command: "update-alternatives --remove-all g++"
39   when: trex_extracted.changed
40
41 - name: Switch to gcc-9
42   ansible.builtin.command: "update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9"
43   when: trex_extracted.changed
44
45 - name: Switch to g++-9
46   ansible.builtin.command: "update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9"
47   when: trex_extracted.changed
48
49 - name: Compile Release {{ item }} Part I
50   ansible.builtin.command: "./b configure"
51   args:
52     chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/linux_dpdk/"
53   when: trex_extracted.changed
54
55 - name: Compile Release {{ item }} Part II
56   ansible.builtin.command: "./b build"
57   args:
58     chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/linux_dpdk/"
59   async: 3000
60   poll: 0
61   register: trex_built
62   when: trex_extracted.changed
63
64 - name: Check if T-Rex is compiled
65   async_status:
66     jid: "{{ trex_built.ansible_job_id }}"
67   register: trex_built
68   until: trex_built.finished
69   delay: 10
70   retries: 300
71   when: trex_extracted.changed
72
73 - name: Switch to gcc-11
74   ansible.builtin.command: "update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11"
75   when: trex_extracted.changed
76
77 - name: Switch to g++-11
78   ansible.builtin.command: "update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11"
79   when: trex_extracted.changed
80
81 - name: Compile Release {{ item }} Part III
82   ansible.builtin.command: "make -j 16"
83   args:
84     chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/scripts/ko/src"
85   when: trex_extracted.changed
86
87 - name: Compile Release {{ item }} Part IV
88   ansible.builtin.command: "make install"
89   args:
90     chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/scripts/ko/src"
91   when: trex_extracted.changed
92
93 - name: Link libc.a to liblibc.a
94   ansible.builtin.command: "ln -s -f /usr/lib/x86_64-linux-gnu/libc.a /usr/lib/x86_64-linux-gnu/liblibc.a"
95   when: trex_extracted.changed