blob: 6e241b2e4a40abf8cf8f3df321cd3818fc0f1fd0 [file] [log] [blame]
Hyunsun Moon4f9c1cd2021-06-03 09:15:55 -07001---
2# sriov tasks/main.yml
3#
4# SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org>
5# SPDX-License-Identifier: Apache-2.0
6
7- name: include OS-specific vars
8 include_vars: "{{ ansible_os_family }}.yml"
9
10- name: include OS-specific tasks
11 include_tasks: "{{ ansible_os_family }}.yml"
12
Hyunsun Moon4f9c1cd2021-06-03 09:15:55 -070013- name: Load vfio_pci module to the kernel
14 modprobe:
15 name: vfio_pci
16 state: present
17 when: ansible_kernel is version('5.4','<')
18
19- name: Set the vfio_pci module to load on boot
20 lineinfile:
21 dest: /etc/modules-load.d/vfio_pci.conf
22 create: true
23 regexp: "^vfio_pci"
24 line: "vfio_pci"
25 mode: 0644
26 when: ansible_kernel is version('5.4','<')
27
28- name: Create sriov system service
29 template:
30 src: "{{ item.src }}"
31 dest: "{{ item.dest }}"
32 mode: "{{ item.mode }}"
33 owner: root
34 group: root
35 loop:
Raphael Vicente Rosa32c53222022-01-28 15:54:37 +010036 - {src: "sriov", dest: "/etc/default/sriov", mode: 644}
37 - {src: "sriov.sh.j2", dest: "/usr/local/bin/sriov.sh", mode: "a+x"}
38 - {
39 src: "sriov.service.j2",
40 dest: "/etc/systemd/system/sriov.service",
41 mode: 644,
42 }
Hyunsun Moon4f9c1cd2021-06-03 09:15:55 -070043 notify: enable sriov.service
44
45- name: Flush handlers
46 meta: flush_handlers
47
48- name: Add kernel boot parameters to the grub
49 lineinfile:
50 dest: /etc/default/grub
51 regexp: '^GRUB_CMDLINE_LINUX="(?!.* {{ item.regex }})(.*)"'
52 line: 'GRUB_CMDLINE_LINUX="\1 {{ item.context }}"'
53 state: present
54 backrefs: true
55 loop:
Raphael Vicente Rosa32c53222022-01-28 15:54:37 +010056 - {regex: "intel_iommu=", context: "intel_iommu=on"}
57 - {regex: "transparent_hugepage=", context: "transparent_hugepage=never"}
58 - {regex: "default_hugepagesz=", context: "default_hugepagesz=1G"}
59 - {
60 regex: "hugepagesz=1G",
61 context: "hugepagesz=1G hugepages={{ sriov_1g_hugepages }}",
62 }
Hyunsun Moon4f9c1cd2021-06-03 09:15:55 -070063 notify: update grub
Raphael Vicente Rosa32c53222022-01-28 15:54:37 +010064
65- name: Install qat driver and configure sriov vfs
66 when: sriov_qat_enabled
67 include_tasks: qat.yml