Support Ubuntu 18.04 and 20.04 LTS as target OS
[kuberef.git] / sw_config / bmra / patched_vfio.yml
1 ##
2 ##   Copyright (c) 2020 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 # check if the selected driver module is available on host
18 - name: Check that selected driver module is available
19   # if modinfo fails, lookup loaded modules as modinfo might return error
20   # for igb_uio and potentially other modules not included with the kernel
21   shell: "modinfo {{ vf_driver }} || grep {{ vf_driver }} /proc/modules || grep {{ vf_driver }} /lib/modules/$(uname -r)/modules.builtin"
22   register: shell_result
23   ignore_errors: yes
24   failed_when: no
25   changed_when: no
26
27 # get a list of VFs PCI addresses and save the configuration
28 - name: attach VFs driver
29   block:
30     - name: fetch VFs pci addresses for a PF
31       shell: "for vf in /sys/class/net/{{ pfname }}/device/virtfn*;do basename $(readlink -f $vf);done"
32       register: vf_pciids
33       args:
34         executable: /bin/bash
35       changed_when: false
36
37     - name: save VF driver binding
38       lineinfile:
39         path: "{{ sriov_config_path }}/bmra_interfaces"
40         line: "{{ this_item }} {{ vf_driver }}"
41         regexp: "^{{ this_item }}"
42         create: yes
43         owner: root
44         group: root
45         mode: '0600'
46       loop: "{{ vf_pciids.stdout_lines }}"
47       loop_control:
48         loop_var: this_item
49       when:
50         - vf_pciids.stderr|length == 0
51         - vf_pciids.stdout_lines|length > 0
52   when: shell_result.rc == 0