Copy generated /boot/grub2/grubenv to EFI dirs

There is an issue with grub2 in rhel-8.2 where generating grub.cfg in
an EFI directory will regenerate grubenv in /boot/grub2. Then when the
host is rebooted, the stale grubenv file in the EFI directory is used,
and any new kernal args are not used.

This change works around this by copying /boot/grub2/grubenv to the
EFI directories. Newer versions of grub2 many not show this behaviour
but the workaround can remain in place.

This change also adds /boot/efi/EFI/BOOT to the list of EFI
directories checked for, as it should have been in the original list.

See https://bugzilla.redhat.com/show_bug.cgi?id=1974507

Change-Id: I4f8664c9033502b25b40646cfd8976cc5638e643
(cherry picked from commit c1d4d602f8)
This commit is contained in:
Steve Baker 2021-07-02 14:19:34 +12:00
parent d2ae49c074
commit eba3be96bd
1 changed files with 16 additions and 5 deletions

View File

@ -53,12 +53,23 @@
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
- /boot/efi/EFI/BOOT
- /boot/efi/EFI/redhat
- /boot/efi/EFI/centos
- /boot/efi/EFI/fedora
- name: Generate grub config
command: "grub2-mkconfig -o {{ item.stat.path }}"
command: "grub2-mkconfig -o /boot/grub2/grub.cfg"
- name: Generate EFI grub config
command: "grub2-mkconfig -o {{ item.stat.path }}/grub.cfg"
when: item.stat.exists|bool
loop: "{{ grub_stat.results }}"
- name: Copy grubenv to EFI directory
copy:
remote_src: true
src: /boot/grub2/grubenv
dest: "{{ item.stat.path }}/grubenv"
when: item.stat.exists|bool
loop: "{{ grub_stat.results }}"
- name: Set reboot required fact