2 # file: roles/trex/tasks/deploy_block.yaml
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"
10 register: trex_downloaded
12 - name: Create Directory {{ item }}
14 path: "{{ trex_target_dir }}/trex-core-{{ item }}"
17 - name: Extract Release {{ item }}
18 ansible.builtin.unarchive:
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
26 ansible.builtin.patch:
27 src: "files/t-rex.patch"
28 basedir: "{{ trex_target_dir }}/trex-core-{{ item }}"
31 - azure is defined and item == "2.73"
34 ansible.builtin.command: "update-alternatives --remove-all gcc"
36 when: trex_extracted.changed
39 ansible.builtin.command: "update-alternatives --remove-all g++"
41 when: trex_extracted.changed
43 - name: Switch to gcc-9
44 ansible.builtin.command: "update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9"
45 when: trex_extracted.changed
47 - name: Switch to g++-9
48 ansible.builtin.command: "update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9"
49 when: trex_extracted.changed
51 - name: Compile Release {{ item }} Part I
52 ansible.builtin.command: "./b configure"
54 chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/linux_dpdk/"
55 when: trex_extracted.changed
57 - name: Compile Release {{ item }} Part II
58 ansible.builtin.command: "./b build"
60 chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/linux_dpdk/"
64 when: trex_extracted.changed
66 - name: Check if T-Rex is Compiled
68 jid: "{{ trex_built.ansible_job_id }}"
70 until: trex_built.finished
73 when: trex_extracted.changed
75 - name: Switch to gcc-11
76 ansible.builtin.command: "update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11"
77 when: trex_extracted.changed
79 - name: Switch to g++-11
80 ansible.builtin.command: "update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11"
81 when: trex_extracted.changed
83 - name: Compile Release {{ item }} Part III
84 ansible.builtin.command: "make -j 16"
86 chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/scripts/ko/src"
87 when: trex_extracted.changed
89 - name: Compile Release {{ item }} Part IV
90 ansible.builtin.command: "make install"
92 chdir: "{{ trex_target_dir }}/trex-core-{{ item }}/scripts/ko/src"
93 when: trex_extracted.changed
95 - name: Link libc.a to liblibc.a
96 ansible.builtin.command: "ln -s -f /usr/lib/x86_64-linux-gnu/libc.a /usr/lib/x86_64-linux-gnu/liblibc.a"
97 when: trex_extracted.changed