[train-only] Fix grubenv linking for minor update

/boot/grub2/grubenv should be symlink to /boot/efi/EFI/redhat/grubenv
on uEFI machines. During deployment[1] on uEFI machines we create both
/boot/grub2/grubenv and /boot/efi/EFI/redhat/grubenv as regular files.
This breaks boot during minor update on second and later kernel update
on the same rhel version as grub package will not override save_entry
with newer kernel version in /boot/efi/EFI/redhat/grubenv during kernel
update, but in /boot/grub2/grubenv instead. Linking is required to be
fixed before yum update step to get correct entry on the nearest kernel
update.

Resolves: rhbz#2233095
[1]https://opendev.org/openstack/tripleo-ansible/src/branch/master/tripleo_ansible/roles/tripleo_kernel/tasks/kernelargs.yml#L159

Change-Id: I31b50563a8d4662fdb7177d97c86f6d9d40cb28b
This commit is contained in:
mciecier 2023-09-19 20:06:01 +02:00
parent 9adcac636e
commit 52c92faade

@ -696,38 +696,20 @@ outputs:
when:
- step|int == 2
- ovs_upgrade.changed|bool
# Exclude ansible until https://github.com/ansible/ansible/issues/56636
# is available
- name: Update all packages
when:
- step|int == 3
- not skip_package_update|bool
yum:
name: '*'
state: latest
exclude: ansible
# This is failsafe unless openvswitch package does something
# to the systemd service state.
- name: Ensure openvswitch is running after update
when: step|int == 3
service:
name: openvswitch
enabled: yes
state: started
ignore_errors: true
# Fix UEFI systems that went through FFWD rhbz#2046456 and rhbz#1925078
# Fix also UEFI systems that went through minor update 16.1->16.2 rhbz#2233095
- name: Check if system was booted via EFI
stat:
path: /sys/firmware/efi
when: step|int == 3
register: efi
- name: Check if red is in efibootmgr
register: efi_red
- name: Check if red or ironic1 is in efibootmgr
register: efi_red_ir
when: step|int == 3
failed_when: false
shell: |
efibootmgr | grep "red$"
- name: Check if red is in efibootmgr
efibootmgr | grep -E 'red$|ironic1'
- name: Check if Red Hat is in efibootmgr
register: efi_redhat
when: step|int == 3
failed_when: false
@ -737,9 +719,9 @@ outputs:
when:
- step|int == 3
- efi.stat.exists|bool
- efi_red.rc is defined
- efi_red_ir.rc is defined
- efi_redhat.rc is defined
- efi_red.rc == 0
- efi_red_ir.rc == 0
- efi_redhat.rc == 0
block:
- name: Check if /boot/grub2/grubenv is symlink
@ -759,3 +741,23 @@ outputs:
dest: /boot/grub2/grubenv
state: link
force: true
# Exclude ansible until https://github.com/ansible/ansible/issues/56636
# is available
- name: Update all packages
when:
- step|int == 3
- not skip_package_update|bool
yum:
name: '*'
state: latest
exclude: ansible
# This is failsafe unless openvswitch package does something
# to the systemd service state.
- name: Ensure openvswitch is running after update
when: step|int == 3
service:
name: openvswitch
enabled: yes
state: started
ignore_errors: true