64 lines
2.3 KiB
YAML
64 lines
2.3 KiB
YAML
---
|
|
- name: Configure Bootloader
|
|
vars:
|
|
_efi_vendor: >-
|
|
{{
|
|
"redhat" if os == "rhel"
|
|
else ("ubuntu" if os in ["ubuntu", "ubuntu-lts"] else os)
|
|
}}
|
|
_efi_loader: "{{ _configuration_platform.efi_loader }}"
|
|
block:
|
|
- name: Install GRUB EFI binary
|
|
when: _configuration_platform.grub_install
|
|
ansible.builtin.command: >-
|
|
{{ chroot_command }} /usr/sbin/grub-install --target=x86_64-efi
|
|
--efi-directory={{ partitioning_efi_mountpoint }}
|
|
--bootloader-id={{ _efi_vendor }}
|
|
--no-nvram
|
|
register: configuration_bootloader_result
|
|
changed_when: configuration_bootloader_result.rc == 0
|
|
|
|
- name: Check existing EFI boot entries
|
|
ansible.builtin.command: efibootmgr
|
|
register: configuration_efi_entries
|
|
changed_when: false
|
|
|
|
- name: Ensure EFI boot entry exists
|
|
when: ('* ' + _efi_vendor) not in configuration_efi_entries.stdout
|
|
ansible.builtin.command: >-
|
|
efibootmgr -c
|
|
-L '{{ _efi_vendor }}'
|
|
-d '{{ install_drive }}'
|
|
-p 1
|
|
-l '\EFI\{{ _efi_vendor }}\{{ _efi_loader }}'
|
|
register: configuration_efi_entry_result
|
|
changed_when: configuration_efi_entry_result.rc == 0
|
|
|
|
- name: Ensure lvm2 for non btrfs filesystems
|
|
when: os == "archlinux" and system_cfg.filesystem != "btrfs"
|
|
ansible.builtin.lineinfile:
|
|
path: /mnt/etc/mkinitcpio.conf
|
|
regexp: "^(HOOKS=.*block)(?!.*lvm2)(.*)"
|
|
line: "\\1 lvm2\\2"
|
|
backrefs: true
|
|
|
|
- name: Regenerate initramfs
|
|
when: _configuration_platform.initramfs_cmd | length > 0
|
|
ansible.builtin.command: "{{ chroot_command }} {{ _configuration_platform.initramfs_cmd }}"
|
|
register: configuration_initramfs_result
|
|
changed_when: configuration_initramfs_result.rc == 0
|
|
|
|
- name: Generate grub config
|
|
vars:
|
|
configuration_grub_cfg_cmd: >-
|
|
{{
|
|
'/usr/sbin/' + _configuration_platform.grub_mkconfig_prefix + ' -o '
|
|
+ partitioning_efi_mountpoint
|
|
+ '/EFI/' + _efi_vendor + '/grub.cfg'
|
|
if os_family == 'RedHat'
|
|
else '/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg'
|
|
}}
|
|
ansible.builtin.command: "{{ chroot_command }} {{ configuration_grub_cfg_cmd }}"
|
|
register: configuration_grub_result
|
|
changed_when: configuration_grub_result.rc == 0
|