8e00cef6ff
In this change [1] I've loaded wrong module. It needs the Type1 IOMMU driver for VFIO to be loaded on boot. [1]: I3ffd1c11a1851e62992a6a63e8abb130db82856f Change-Id: Iba7fa6c4edea4755afb91a97460ec3cc8e7ee234 Closes-Bug: 1838159
102 lines
4.2 KiB
YAML
102 lines
4.2 KiB
YAML
- name: Get the command line args of the node
|
|
command: cat /proc/cmdline
|
|
register: cmdline
|
|
|
|
- name: Check tuned active profile
|
|
slurp:
|
|
src: "/etc/tuned/active_profile"
|
|
register: tuned_active_profile
|
|
|
|
# Kernel Args Configuration
|
|
- block:
|
|
- name: Ensure the kernel args ( {{ _KERNEL_ARGS_ }} ) is present as TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS
|
|
lineinfile:
|
|
dest: /etc/default/grub
|
|
regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
|
|
insertafter: '^GRUB_CMDLINE_LINUX.*'
|
|
line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ _KERNEL_ARGS_ }} "'
|
|
- name: Add TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS to the GRUB_CMDLINE_LINUX parameter
|
|
lineinfile:
|
|
dest: /etc/default/grub
|
|
line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"'
|
|
insertafter: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
|
|
- name: Generate grub config file
|
|
command: grub2-mkconfig -o /boot/grub2/grub.cfg
|
|
- name: Set reboot required fact
|
|
set_fact:
|
|
reboot_required: true
|
|
become: true
|
|
when:
|
|
- _KERNEL_ARGS_|default("") != ""
|
|
- _KERNEL_ARGS_|default("") not in cmdline.stdout_lines[0]
|
|
|
|
# Kernel modules loading
|
|
- name: Load type1 IOMMU driver for VFIO on boot
|
|
import_role:
|
|
name: tripleo-module-load
|
|
vars:
|
|
modules:
|
|
- name: vfio_iommu_type1
|
|
when: _KERNEL_ARGS_ is search("iommu")
|
|
|
|
# Tune-d Configuration
|
|
- block:
|
|
- name: Check Tune-d Configuration file exists
|
|
stat:
|
|
path: "/etc/tuned/{{ _TUNED_PROFILE_NAME_ }}-variables.conf"
|
|
register: tuned_conf_stat_result
|
|
|
|
- name: Tune-d Configuration
|
|
lineinfile:
|
|
dest: "/etc/tuned/{{ _TUNED_PROFILE_NAME_ }}-variables.conf"
|
|
regexp: '^isolated_cores=.*'
|
|
line: 'isolated_cores={{ _TUNED_CORES_ }}'
|
|
when: tuned_conf_stat_result.stat.exists and _TUNED_CORES_|default("") != ""
|
|
|
|
- name: Tune-d profile activation
|
|
command: >-
|
|
tuned-adm profile {{ _TUNED_PROFILE_NAME_ }}
|
|
|
|
- name: Set reboot required fact
|
|
set_fact:
|
|
reboot_required: true
|
|
become: true
|
|
when:
|
|
- (_TUNED_PROFILE_NAME_ | default("")) != ""
|
|
- (_TUNED_PROFILE_NAME_ | default("")) != (tuned_active_profile['content'] | b64decode).strip()
|
|
|
|
# Check if os-net-config has run once, if yes, no need for the below workaround
|
|
- find:
|
|
paths: /etc/sysconfig/network-scripts/
|
|
patterns: ifcfg-*
|
|
contains: "# This file is autogenerated by os-net-config"
|
|
register: os_net_ifcfg_files
|
|
when: reboot_required is defined and reboot_required
|
|
|
|
# Provisioning Network workaround
|
|
# The script will be executed before os-net-config, in which case, only Provisioning network will have IP
|
|
# BOOTPROTO of all interface config files (except provisioning), will be set to "none" to avoid reboot failing to acquire IP on other networks
|
|
- block:
|
|
- find:
|
|
paths: /etc/sysconfig/network-scripts/
|
|
patterns: ifcfg-*
|
|
register: ifcfg_files
|
|
|
|
- replace:
|
|
dest: "{{ item.path }}"
|
|
regexp: '^BOOTPROTO=.*'
|
|
replace: 'BOOTPROTO=none'
|
|
when:
|
|
- item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') != "lo"
|
|
# Ensure the interface information is available in the facts
|
|
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ] is defined
|
|
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
|
|
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined
|
|
- hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_') ]['ipv4'] is undefined
|
|
with_items:
|
|
- "{{ ifcfg_files.files }}"
|
|
become: true
|
|
when:
|
|
- reboot_required is defined and reboot_required
|
|
- os_net_ifcfg_files.matched == 0
|