tripleo-ansible/tripleo_ansible/roles/tripleo_kernel/tasks/kernelargs.yml

104 lines
3.6 KiB
YAML

---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Get the command line args of the node
command: cat /proc/cmdline
register: cmdline
- name: Check if the kernelargs entry is already present in the file
replace:
regexp: TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS
dest: /etc/default/grub
replace: ''
check_mode: true
register: grub_file_entry_check
# Kernel Args Configuration
- block:
# Leapp does not recognise grun entries starting other than GRUB
# It results wrong formatting of entries in file /etc/default/grub
# In order to fix it for FFU (queens to train), TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS has been renamed
# Ensure the fresh deployment is also alinged with the same name
- name: Delete older name TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS entries if present
lineinfile:
dest: /etc/default/grub
regexp: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS'
state: absent
- name: Ensure the kernel args ( {{ tripleo_kernel_args }} ) is present as GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS
lineinfile:
dest: /etc/default/grub
regexp: '^GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
insertafter: '^GRUB_CMDLINE_LINUX.*'
line: 'GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ tripleo_kernel_args }} "'
- name: Add GRUB_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 }${GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"'
insertafter: '^GRUB_TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
- name: Check grub config paths
stat:
path: "{{ item }}"
register: grub_stat
loop:
- /boot/grub2/grub.cfg
- /boot/efi/EFI/redhat/grub.cfg
- /boot/efi/EFI/centos/grub.cfg
- /boot/efi/EFI/fedora/grub.cfg
- name: Generate grub config
command: "grub2-mkconfig -o {{ item.stat.path }}"
when: item.stat.exists|bool
loop: "{{ grub_stat.results }}"
- name: Set reboot required fact
set_fact:
reboot_required: true
become: true
when:
- cmdline.stdout_lines is defined
- tripleo_kernel_args|string
- tripleo_kernel_args not in cmdline.stdout_lines[0]
# Apply DPDK workarounds before reboot
- name: Apply DPDK workarounds
include_role:
name: tripleo_ovs_dpdk
tasks_from: workarounds.yml
when: reboot_required is defined and reboot_required
# 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: tripleo_kernel_args is search("iommu")
- name: Reboot block
when:
- reboot_required is defined and reboot_required
- not tripleo_kernel_defer_reboot|bool
block:
- name: Reboot tasks
include_tasks: reboot.yaml
when:
- grub_file_entry_check is not changed
- name: Skipping reboot for deployed node
debug:
msg: "Reboot is skipped for kernel arg change, user has to plan the reboot with migration and downtime"
when:
- grub_file_entry_check is changed