refactor(configuration): add platform_config dict and replace is_rhel/is_debian with os_family lookups

This commit is contained in:
2026-02-22 02:26:54 +01:00
parent cc30637f09
commit 3deb3ea751
11 changed files with 101 additions and 44 deletions

View File

@@ -134,7 +134,7 @@
- name: Ensure keyfile pattern for initramfs-tools
when:
- is_debian | bool
- os_family == 'Debian'
- configuration_luks_keyfile_in_use
ansible.builtin.lineinfile:
path: /mnt/etc/cryptsetup-initramfs/conf-hook
@@ -198,14 +198,14 @@
}})
- name: Ensure dracut config directory exists
when: is_rhel | bool
when: os_family == 'RedHat'
ansible.builtin.file:
path: /mnt/etc/dracut.conf.d
state: directory
mode: "0755"
- name: Configure dracut for LUKS
when: is_rhel | bool
when: os_family == 'RedHat'
ansible.builtin.copy:
dest: /mnt/etc/dracut.conf.d/crypt.conf
content: |
@@ -216,13 +216,13 @@
mode: "0644"
- name: Read kernel cmdline defaults
when: is_rhel | bool
when: os_family == 'RedHat'
ansible.builtin.slurp:
src: /mnt/etc/kernel/cmdline
register: configuration_kernel_cmdline_slurp
- name: Build kernel cmdline with LUKS args
when: is_rhel | bool
when: os_family == 'RedHat'
vars:
kernel_cmdline_current: >-
{{ configuration_kernel_cmdline_slurp.content | b64decode | trim }}
@@ -247,14 +247,14 @@
configuration_kernel_cmdline_new: "{{ kernel_cmdline_new }}"
- name: Write kernel cmdline with LUKS args
when: is_rhel | bool
when: os_family == 'RedHat'
ansible.builtin.copy:
dest: /mnt/etc/kernel/cmdline
mode: "0644"
content: "{{ configuration_kernel_cmdline_new }}\n"
- name: Find BLS entries for encryption kernel cmdline
when: is_rhel | bool
when: os_family == 'RedHat'
ansible.builtin.find:
paths: /mnt/boot/loader/entries
patterns: "*.conf"
@@ -263,7 +263,7 @@
- name: Update BLS options with LUKS args
when:
- is_rhel | bool
- os_family == 'RedHat'
- configuration_kernel_bls_entries.files | length > 0
ansible.builtin.lineinfile:
path: "{{ item.path }}"
@@ -274,13 +274,13 @@
label: "{{ item.path }}"
- name: Read grub defaults
when: not is_rhel | bool
when: not os_family == 'RedHat'
ansible.builtin.slurp:
src: /mnt/etc/default/grub
register: configuration_grub_slurp
- name: Build grub command lines with LUKS args
when: not is_rhel | bool
when: not os_family == 'RedHat'
vars:
grub_content: "{{ configuration_grub_slurp.content | b64decode }}"
grub_cmdline_linux: >-
@@ -344,7 +344,7 @@
configuration_grub_cmdline_default_new: "{{ grub_cmdline_default_new }}"
- name: Update GRUB_CMDLINE_LINUX_DEFAULT for LUKS
when: not is_rhel | bool
when: not os_family == 'RedHat'
ansible.builtin.lineinfile:
path: /mnt/etc/default/grub
regexp: "^GRUB_CMDLINE_LINUX_DEFAULT="