From 5c2e1aae521c980d25e6bdba39f150a98f82c9d5 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Tue, 23 Apr 2024 22:58:19 +0200 Subject: [PATCH 1/2] chore: Distinguish between EL 7 workarounds and proper config tasks --- handlers/main.yml | 10 ++++++++++ tasks/main.yml | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 0242dfc..c46055f 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -11,6 +11,16 @@ {{ __bootloader_default_grub }} cat {{ __bootloader_default_grub }} changed_when: true + when: + - ansible_distribution in ['CentOS', 'RedHat'] + - ansible_distribution_version is version('8', '<') - name: Reboot system include_tasks: tasks/reboot.yml + +# This doesn't work on EL 7. EL 7 has it's workaround in tasks/main.yml +- name: Regenerate grub config + command: grub2-mkconfig -o {{ __bootloader_grub_conf }} + when: >- + not (ansible_distribution in ['CentOS', 'RedHat'] and + ansible_distribution_version is version('8', '<')) diff --git a/tasks/main.yml b/tasks/main.yml index 3875f38..c62b31a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -75,22 +75,26 @@ set_fact: __bootloader_grub_conf: /boot/grub2/grub.cfg -- name: >- - Update boot loader timeout configuration in {{ __bootloader_default_grub }} +- name: Update timeout configuration in {{ __bootloader_default_grub }} replace: path: "{{ __bootloader_default_grub }}" regexp: '^GRUB_TIMEOUT=.*' replace: 'GRUB_TIMEOUT={{ bootloader_timeout }}' mode: "{{ __bootloader_default_grub_stat.stat.exists | ternary(__bootloader_default_grub_stat.stat.mode, '0644') }}" + notify: Regenerate grub config -- name: Update boot loader timeout configuration in {{ __bootloader_grub_conf }} +# Regenerate grub config doesn't work on EL 7, need to edit config manually +- name: On EL 7, update timeout configuration in {{ __bootloader_grub_conf }} replace: path: "{{ __bootloader_grub_conf }}" regexp: 'set timeout=.*' replace: 'set timeout={{ bootloader_timeout }}' mode: "{{ __bootloader_grub_conf_stat.stat.exists | ternary(__bootloader_grub_conf_stat.stat.mode, '0644') }}" + when: + - ansible_distribution in ['CentOS', 'RedHat'] + - ansible_distribution_version is version('8', '<') - name: Ensure boot loader settings bootloader_settings: From e42abbc5746033e7fdca8eda4d70da0f0869b267 Mon Sep 17 00:00:00 2001 From: Sergei Petrosian Date: Wed, 24 Apr 2024 17:58:19 +0200 Subject: [PATCH 2/2] Fix default kernel boot parameters on all platforms --- handlers/main.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index c46055f..c001bf0 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT --- -# EL 7 workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1152027 +# A workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1152027 - name: Fix default kernel boot parameters shell: |- set -o pipefail @@ -11,9 +11,6 @@ {{ __bootloader_default_grub }} cat {{ __bootloader_default_grub }} changed_when: true - when: - - ansible_distribution in ['CentOS', 'RedHat'] - - ansible_distribution_version is version('8', '<') - name: Reboot system include_tasks: tasks/reboot.yml @@ -24,3 +21,4 @@ when: >- not (ansible_distribution in ['CentOS', 'RedHat'] and ansible_distribution_version is version('8', '<')) + changed_when: true