refactor(configuration): add platform_config dict and replace is_rhel/is_debian with os_family lookups
This commit is contained in:
@@ -6,11 +6,10 @@
|
||||
"redhat" if os == "rhel"
|
||||
else ("ubuntu" if os in ["ubuntu", "ubuntu-lts"] else os)
|
||||
}}
|
||||
_efi_loader: >-
|
||||
{{ "shimx64.efi" if is_rhel | bool else "grubx64.efi" }}
|
||||
_efi_loader: "{{ _configuration_platform.efi_loader }}"
|
||||
block:
|
||||
- name: Install GRUB EFI binary
|
||||
when: not (is_rhel | bool)
|
||||
when: _configuration_platform.grub_install
|
||||
ansible.builtin.command: >-
|
||||
{{ chroot_command }} /usr/sbin/grub-install --target=x86_64-efi
|
||||
--efi-directory={{ partitioning_efi_mountpoint }}
|
||||
@@ -44,20 +43,8 @@
|
||||
backrefs: true
|
||||
|
||||
- name: Regenerate initramfs
|
||||
when: os not in ["alpine", "void"]
|
||||
vars:
|
||||
configuration_initramfs_cmd: >-
|
||||
{{
|
||||
'/usr/sbin/mkinitcpio -P'
|
||||
if os == "archlinux"
|
||||
else (
|
||||
'/usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin '
|
||||
+ '/usr/sbin/update-initramfs -u -k all'
|
||||
if is_debian | bool
|
||||
else '/usr/bin/dracut --regenerate-all --force'
|
||||
)
|
||||
}}
|
||||
ansible.builtin.command: "{{ chroot_command }} {{ configuration_initramfs_cmd }}"
|
||||
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
|
||||
|
||||
@@ -65,10 +52,10 @@
|
||||
vars:
|
||||
configuration_grub_cfg_cmd: >-
|
||||
{{
|
||||
'/usr/sbin/grub2-mkconfig -o '
|
||||
'/usr/sbin/' + _configuration_platform.grub_mkconfig_prefix + ' -o '
|
||||
+ partitioning_efi_mountpoint
|
||||
+ '/EFI/' + _efi_vendor + '/grub.cfg'
|
||||
if is_rhel | bool
|
||||
if os_family == 'RedHat'
|
||||
else '/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg'
|
||||
}}
|
||||
ansible.builtin.command: "{{ chroot_command }} {{ configuration_grub_cfg_cmd }}"
|
||||
|
||||
Reference in New Issue
Block a user