fix(configuration): RedHat EFI grub wrapper with btrfs subvol prefix and boot order
This commit is contained in:
@@ -34,6 +34,16 @@
|
|||||||
register: configuration_efi_entry_result
|
register: configuration_efi_entry_result
|
||||||
changed_when: configuration_efi_entry_result.rc == 0
|
changed_when: configuration_efi_entry_result.rc == 0
|
||||||
|
|
||||||
|
- name: Set installed OS as first EFI boot entry
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: >-
|
||||||
|
set -o pipefail &&
|
||||||
|
efibootmgr | grep -i '{{ _efi_vendor }}' | grep -oP 'Boot\K[0-9A-F]+' | head -1
|
||||||
|
| xargs -I{} efibootmgr -o {}
|
||||||
|
executable: /bin/bash
|
||||||
|
register: _efi_bootorder_result
|
||||||
|
changed_when: _efi_bootorder_result.rc == 0
|
||||||
|
|
||||||
- name: Ensure lvm2 for non btrfs filesystems
|
- name: Ensure lvm2 for non btrfs filesystems
|
||||||
when: os == "archlinux" and system_cfg.filesystem != "btrfs"
|
when: os == "archlinux" and system_cfg.filesystem != "btrfs"
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
@@ -48,14 +58,48 @@
|
|||||||
register: configuration_initramfs_result
|
register: configuration_initramfs_result
|
||||||
changed_when: configuration_initramfs_result.rc == 0
|
changed_when: configuration_initramfs_result.rc == 0
|
||||||
|
|
||||||
- name: Generate grub config
|
- name: Generate grub config (RedHat)
|
||||||
vars:
|
when: os_family == 'RedHat'
|
||||||
configuration_grub_cfg_cmd: >-
|
ansible.builtin.command: >-
|
||||||
{{
|
{{ chroot_command }} /usr/sbin/{{ _configuration_platform.grub_mkconfig_prefix }}
|
||||||
'/usr/sbin/' + _configuration_platform.grub_mkconfig_prefix + ' -o /boot/grub2/grub.cfg'
|
-o /boot/grub2/grub.cfg
|
||||||
if os_family == 'RedHat'
|
register: configuration_grub_result
|
||||||
else '/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg'
|
changed_when: configuration_grub_result.rc == 0
|
||||||
}}
|
|
||||||
ansible.builtin.command: "{{ chroot_command }} {{ configuration_grub_cfg_cmd }}"
|
- name: Fix btrfs BLS boot variable in grub config
|
||||||
|
when:
|
||||||
|
- os_family == 'RedHat'
|
||||||
|
- system_cfg.filesystem == 'btrfs'
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: /mnt/boot/grub2/grub.cfg
|
||||||
|
regexp: 'search --no-floppy --fs-uuid --set=boot \S+'
|
||||||
|
replace: 'set boot=$root'
|
||||||
|
|
||||||
|
- name: Create EFI grub.cfg wrapper for RedHat
|
||||||
|
when: os_family == 'RedHat'
|
||||||
|
vars:
|
||||||
|
_grub2_path: >-
|
||||||
|
{{
|
||||||
|
'/grub2'
|
||||||
|
if (partitioning_separate_boot | bool)
|
||||||
|
else ('/@/boot/grub2' if system_cfg.filesystem == 'btrfs' else '/boot/grub2')
|
||||||
|
}}
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: |
|
||||||
|
set -o pipefail
|
||||||
|
uuid=$(grep -m1 'search.*--set=root' /mnt/boot/grub2/grub.cfg | grep -oP '[\da-f]{8}(-[\da-f]{4}){3}-[\da-f]{12}')
|
||||||
|
cat > /mnt{{ partitioning_efi_mountpoint }}/EFI/{{ _efi_vendor }}/grub.cfg <<GRUBEOF
|
||||||
|
search --no-floppy --fs-uuid --set=dev $uuid
|
||||||
|
set prefix=(\$dev){{ _grub2_path }}
|
||||||
|
export \$prefix
|
||||||
|
configfile \$prefix/grub.cfg
|
||||||
|
GRUBEOF
|
||||||
|
executable: /bin/bash
|
||||||
|
register: _grub_wrapper_result
|
||||||
|
changed_when: _grub_wrapper_result.rc == 0
|
||||||
|
|
||||||
|
- name: Generate grub config (non-RedHat)
|
||||||
|
when: os_family != 'RedHat'
|
||||||
|
ansible.builtin.command: "{{ chroot_command }} /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg"
|
||||||
register: configuration_grub_result
|
register: configuration_grub_result
|
||||||
changed_when: configuration_grub_result.rc == 0
|
changed_when: configuration_grub_result.rc == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user