diff --git a/defaults/main.yml b/defaults/main.yml index e2dbeec..e83432f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,3 +11,5 @@ kernel_blacklist_modules: kernel_namespace_support_enabled: False kernel_coredump_enabled: True kernel_cgroup_v2_enabled: False + +kernel_grub_rebuild_force: False diff --git a/handlers/main.yml b/handlers/main.yml index d118017..fb4a75c 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -5,6 +5,15 @@ become: True become_user: root +- name: Rebuild grub config + command: "{{ item }}" + listen: __kernel_grub_rebuild + loop: + - grub2-mkconfig -o /boot/grub2/grub.cfg + - grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg + become: True + become_user: root + - name: Reboot server reboot: reboot_timeout: 600 diff --git a/molecule/rocky8/tests/test_default.py b/molecule/rocky8/tests/test_default.py index 0861e57..3d6d2d7 100644 --- a/molecule/rocky8/tests/test_default.py +++ b/molecule/rocky8/tests/test_default.py @@ -35,7 +35,7 @@ def test_coredump_config(host): def test_cgroup_config(host): grub = host.file("/boot/grub2/grubenv") - proc = host.run("grep cgroup /proc/filesystems") + proc = host.run("mount -l | grep cgroup") assert grub.contains("systemd.unified_cgroup_hierarchy=1") - assert "cgroup2" in proc.stdout + assert "cgroup2 on /sys/fs/cgroup type cgroup2" in proc.stdout diff --git a/tasks/cgroup.yml b/tasks/cgroup.yml index 5cba2f2..3298d29 100644 --- a/tasks/cgroup.yml +++ b/tasks/cgroup.yml @@ -17,12 +17,21 @@ - __kernel_cgroup_exception.rc != 0 - kernel_cgroup_v2_enabled | bool notify: + - __kernel_grub_rebuild - __kernel_server_restart - name: Disable cgroup v2 configuration - command: grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0" + command: grubby --update-kernel=ALL --remove-args="systemd.unified_cgroup_hierarchy" when: - __kernel_cgroup_exception.rc == 0 - not kernel_cgroup_v2_enabled | bool notify: + - __kernel_grub_rebuild - __kernel_server_restart + +- name: Force rebuild grub config and reboot + command: /bin/true + notify: + - __kernel_grub_rebuild + - __kernel_server_restart + when: kernel_grub_rebuild_force | bool