Fix bugs with preflight check and DPDK dependency
[kuberef.git] / sw_config / bmra / patched_install_dpdk_meson.yml
1 ##
2 ##   Copyright (c) 2020-2021 Intel Corporation.
3 ##
4 ##   Licensed under the Apache License, Version 2.0 (the "License");
5 ##   you may not use this file except in compliance with the License.
6 ##   You may obtain a copy of the License at
7 ##
8 ##       http://www.apache.org/licenses/LICENSE-2.0
9 ##
10 ##   Unless required by applicable law or agreed to in writing, software
11 ##   distributed under the License is distributed on an "AS IS" BASIS,
12 ##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ##   See the License for the specific language governing permissions and
14 ##   limitations under the License.
15 ##
16 ---
17 - name: install Python3 from epel-release
18   package:
19     name:
20       - python36
21       - python36-devel
22       - libselinux-python
23     state: present
24     enablerepo: "epel"
25   when:
26     - ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS'
27     - ansible_distribution_version < '8'
28
29 - name: install dpdk-devel required for libraries enablement in RHEL / CentOS >= 8.2
30   dnf:
31     name: dpdk-devel
32   when: ansible_distribution in ["RedHat", "CentOS"] and ansible_distribution_version >= '8.2'
33
34 - name: build and install dpdk using meson and ninja tools
35   block:
36     - name: install building tools as python packages
37       pip:
38         name:
39           - selinux
40           - meson>=0.53.2,<0.60.0
41           - ninja>=1.10.0
42           - pyelftools>=0.26
43         state: present
44       register: pip_result
45       retries: 5
46       until: pip_result is succeeded
47       delay: 5
48
49     - name: meson build for ease of compiling and linking libraries enablement
50       command: "meson build"
51       args:
52         chdir: "{{ dpdk_dir }}"
53
54     - name: configure DPDK with ninja
55       command: "ninja"
56       args:
57         chdir: "{{ dpdk_dir }}/build"
58
59     - name: install DPDK with ninja
60       command: "ninja install"
61       args:
62         chdir: "{{ dpdk_dir }}/build"
63
64     - name: update the dynamic linker cache
65       command: "ldconfig"
66       args:
67         chdir: "{{ dpdk_dir }}/build"
68   vars:
69     ansible_python_interpreter: /usr/bin/python3
70
71 - name: Ensure dpdk libs is in loader search path on RHEL/CentOS
72   copy:
73     dest: "/etc/ld.so.conf.d/libdpdk-x86_64.conf"
74     content: "/usr/local/lib64/"
75     mode: 0644
76     owner: root
77     group: root
78   become: yes
79   when: ansible_os_family == "RedHat"
80
81 - name: find dpdk tools
82   find:
83     path: "{{ dpdk_dir }}"
84     patterns: "dpdk-devbind.py"
85     recurse: yes
86   register: dpdk_tools_dir
87
88 - name: set path to dpdk usertools directory
89   set_fact:
90     dpdk_tools: "{{ dpdk_tools_dir.files[0].path }}"
91
92 - name: load userspace modules
93   modprobe:
94     name: "{{ item }}"
95     state: present
96   with_items:
97     - vfio-pci
98     - uio
99
100 - name: install dpdk-devbind.py in /usr/local/bin
101   copy:
102     remote_src: yes
103     src: "{{ dpdk_tools }}"
104     dest: "/usr/local/bin/dpdk-devbind.py"
105     mode: 0700
106     owner: root
107     group: root
108   become: yes
109
110 - name: clone intel module
111   git:
112     repo: "{{ dpdk_kmods_repo }}"
113     dest: "{{ dpdk_kmods_dest }}"
114     version: 'main'
115     force: yes
116
117 - name: apply fix to Makefile
118   replace:
119     path: "{{ dpdk_kmods_dest }}/linux/igb_uio/Makefile"
120     regexp: "\\(PWD\\)"
121     replace: "(CURDIR)"
122     mode: "0644"
123
124 - name: build intel module
125   make:
126     chdir: "{{ dpdk_kmods_dest }}/linux/igb_uio"
127
128 - name: load intel module
129   command: "insmod {{ dpdk_kmods_dest }}/linux/igb_uio/igb_uio.ko"
130   register: result
131   failed_when: "'No such file or directory' in result.stderr"
132   changed_when: "'already bound' not in result.stderr"