Normalize user-facing defaults

This commit is contained in:
2025-12-28 16:41:11 +01:00
parent cc77f646d7
commit 7fe2a0dcc1
26 changed files with 283 additions and 222 deletions

View File

@@ -32,26 +32,26 @@
- install_type in ["virtual", "physical"]
- hypervisor in ["libvirt", "proxmox", "vmware", "none"]
- filesystem in ["btrfs", "ext4", "xfs"]
- install_drive is defined
- install_type == "physical" or vm_size is defined
- install_type == "physical" or vm_memory is defined
- install_drive | length > 0
- install_type == "physical" or (vm_size | float) > 0
- install_type == "physical" or (vm_memory | float) > 0
- os in ["archlinux", "almalinux", "debian11", "debian12", "debian13", "fedora", "rhel8", "rhel9", "rhel10", "rocky", "ubuntu", "ubuntu-lts"]
- os not in ["rhel8", "rhel9", "rhel10"] or rhel_iso is defined
- os not in ["rhel8", "rhel9", "rhel10"] or rhel_iso | length > 0
- >-
install_type == "physical"
or (
(filesystem == "btrfs" and (vm_size | default(0) | int) >= 10)
or (filesystem != "btrfs" and (vm_size | default(0) | int) >= 20)
(filesystem == "btrfs" and (vm_size | int) >= 10)
or (filesystem != "btrfs" and (vm_size | int) >= 20)
)
- >-
install_type == "physical"
or (
(vm_size | default(0) | float)
(vm_size | float)
>= (
(vm_memory | default(0) | float / 1024 >= 16.0)
(vm_memory | float / 1024 >= 16.0)
| ternary(
(vm_memory | default(0) | float / 2048),
[vm_memory | default(0) | float / 1024, 4.0] | max
(vm_memory | float / 2048),
[vm_memory | float / 1024, 4.0] | max
)
+ 16
)
@@ -60,10 +60,10 @@
- name: Normalize optional flags
ansible.builtin.set_fact:
cis: "{{ cis | default(false) | bool }}"
custom_iso: "{{ custom_iso | default(false) | bool }}"
is_rhel: "{{ os | default('') | lower in ['almalinux', 'fedora', 'rhel8', 'rhel9', 'rhel10', 'rocky'] }}"
is_debian: "{{ os | default('') | lower in ['debian11', 'debian12', 'debian13', 'ubuntu', 'ubuntu-lts'] }}"
cis: "{{ cis | bool }}"
custom_iso: "{{ custom_iso | bool }}"
is_rhel: "{{ os | lower in ['almalinux', 'fedora', 'rhel8', 'rhel9', 'rhel10', 'rocky'] }}"
is_debian: "{{ os | lower in ['debian11', 'debian12', 'debian13', 'ubuntu', 'ubuntu-lts'] }}"
changed_when: false
- name: Set Python interpreter for RHEL-based installers
@@ -110,7 +110,7 @@
- role: configuration
- role: cis
when: cis | default(false) | bool
when: cis | bool
- role: cleanup
when: install_type in ["virtual", "physical"]
@@ -122,7 +122,7 @@
post_reboot_can_connect: >-
{{
(ansible_connection | default('ssh')) != 'ssh'
or ((vm_ip | default('') | string | length) > 0)
or ((vm_ip | string | length) > 0)
or (
install_type == 'physical'
and (ansible_host | default('') | string | length) > 0
@@ -132,7 +132,7 @@
- name: Set final SSH credentials for post-reboot tasks
when:
- post_reboot_can_connect | default(false) | bool
- post_reboot_can_connect | bool
ansible.builtin.set_fact:
ansible_user: "{{ user_name }}"
ansible_password: "{{ user_password }}"
@@ -141,8 +141,8 @@
- name: Install post-reboot extra packages
when:
- extra_packages is defined
- post_reboot_can_connect | default(false) | bool
- post_reboot_can_connect | bool
- extra_packages | length > 0
block:
- name: Normalize extra package list
ansible.builtin.set_fact:
@@ -151,7 +151,7 @@
(
extra_packages
if (extra_packages is iterable and extra_packages is not string)
else (extra_packages | default('') | string).split(',')
else (extra_packages | string).split(',')
)
| map('trim')
| reject('equalto', '')