ce72766b97
Update /etc/tuned/{{ _TUNED_PROFILE_NAME_ }}-variables.conf only if it exists. Change-Id: I20562efd61ba49b3ae0af62c079967681e05aeed Closes-Bug: #1806812
90 lines
3.9 KiB
YAML
90 lines
3.9 KiB
YAML
- name: Get the command line args of the node
|
|
command: cat /proc/cmdline
|
|
register: cmdline
|
|
|
|
- name: Get the active tuned profile
|
|
command: tuned-adm active
|
|
become: true
|
|
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]
|
|
|
|
# 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
|
|
shell: 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("") not in tuned_active_profile.stdout_lines[0]
|
|
|
|
# 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
|