refactor(vars): add system/hypervisor dict inputs
This commit is contained in:
@@ -4,96 +4,59 @@
|
||||
msg: Global defaults loaded.
|
||||
changed_when: false
|
||||
|
||||
- name: Normalize hypervisor inputs
|
||||
ansible.builtin.include_tasks: hypervisor.yml
|
||||
|
||||
- name: Normalize system inputs
|
||||
ansible.builtin.include_tasks: system.yml
|
||||
|
||||
- name: Validate variables
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install_type is defined and install_type in ["virtual", "physical"]
|
||||
- hypervisor in ["libvirt", "proxmox", "vmware", "none"]
|
||||
- >-
|
||||
install_type is defined and (
|
||||
install_type == "physical"
|
||||
or hypervisor in ["libvirt", "proxmox", "vmware"]
|
||||
)
|
||||
- filesystem is defined and filesystem in ["btrfs", "ext4", "xfs"]
|
||||
- install_drive is defined and install_drive | length > 0
|
||||
- hostname is defined and hostname | length > 0
|
||||
- >-
|
||||
os is defined and os in [
|
||||
"archlinux", "almalinux", "debian11", "debian12", "debian13", "fedora",
|
||||
"rhel8", "rhel9", "rhel10", "rocky", "ubuntu", "ubuntu-lts"
|
||||
]
|
||||
- >-
|
||||
os is defined and (
|
||||
os not in ["rhel8", "rhel9", "rhel10"]
|
||||
or (rhel_iso is defined and rhel_iso | length > 0)
|
||||
)
|
||||
- >-
|
||||
install_type is defined and (
|
||||
install_type == "physical"
|
||||
or (boot_iso is defined and boot_iso | length > 0)
|
||||
)
|
||||
- >-
|
||||
install_type is defined and (
|
||||
install_type == "physical"
|
||||
or (vm_cpus is defined and (vm_cpus | int) > 0)
|
||||
)
|
||||
- >-
|
||||
install_type is defined and (
|
||||
install_type == "physical"
|
||||
or (vm_size is defined and (vm_size | float) > 0)
|
||||
)
|
||||
- >-
|
||||
install_type is defined and (
|
||||
install_type == "physical"
|
||||
or (vm_memory is defined and (vm_memory | float) > 0)
|
||||
)
|
||||
- >-
|
||||
install_type is defined and filesystem is defined and (
|
||||
install_type == "physical"
|
||||
or (
|
||||
vm_size is defined
|
||||
and (vm_size | int) >= 20
|
||||
)
|
||||
)
|
||||
- >-
|
||||
install_type is defined and (
|
||||
install_type == "physical"
|
||||
or (
|
||||
vm_size is defined
|
||||
and vm_memory is defined
|
||||
and filesystem is defined
|
||||
and (
|
||||
filesystem != "btrfs"
|
||||
or (
|
||||
(vm_size | float)
|
||||
>= (
|
||||
(vm_memory | float / 1024 >= 16.0)
|
||||
| ternary(
|
||||
(vm_memory | float / 2048),
|
||||
[vm_memory | float / 1024, 4.0] | max
|
||||
)
|
||||
+ 5.5
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
- >-
|
||||
vm_ip is not defined
|
||||
or vm_ip | length == 0
|
||||
or (vm_nms is defined and (vm_nms | int) > 0)
|
||||
fail_msg: Invalid input specified, please try again.
|
||||
ansible.builtin.include_tasks: validation.yml
|
||||
|
||||
- name: Set OS family flags
|
||||
ansible.builtin.set_fact:
|
||||
is_rhel: "{{ os | lower in ['almalinux', 'fedora', 'rhel8', 'rhel9', 'rhel10', 'rocky'] }}"
|
||||
is_debian: "{{ os | lower in ['debian11', 'debian12', 'debian13', 'ubuntu', 'ubuntu-lts'] }}"
|
||||
is_rhel: "{{ os | lower in ['almalinux', 'fedora', 'rhel', 'rocky'] }}"
|
||||
is_debian: "{{ os | lower in ['debian', 'ubuntu', 'ubuntu-lts'] }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Normalize OS version for keying
|
||||
when:
|
||||
- os_version is defined
|
||||
- (os_version | string | length) > 0
|
||||
ansible.builtin.set_fact:
|
||||
os_version_major: "{{ (os_version | string).split('.')[0] }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Resolve final OS key with version
|
||||
when:
|
||||
- os_version is defined
|
||||
- (os_version | string | length) > 0
|
||||
ansible.builtin.set_fact:
|
||||
os_resolved: >-
|
||||
{{
|
||||
'debian' + os_version | string if os == 'debian'
|
||||
else 'fedora' + os_version | string if os == 'fedora'
|
||||
else 'rocky' + os_version_major if os == 'rocky'
|
||||
else 'almalinux' + os_version_major if os == 'almalinux'
|
||||
else 'rhel' + os_version_major if os == 'rhel'
|
||||
else os
|
||||
}}
|
||||
changed_when: false
|
||||
|
||||
- name: Set chroot command wrapper
|
||||
ansible.builtin.set_fact:
|
||||
chroot_command: >-
|
||||
{{
|
||||
'systemd-nspawn -D /mnt'
|
||||
if chroot_tool == 'systemd-nspawn'
|
||||
else chroot_tool ~ ' /mnt'
|
||||
}}
|
||||
changed_when: false
|
||||
|
||||
- name: Set Python interpreter for RHEL-based installers
|
||||
when:
|
||||
- ansible_python_interpreter is not defined
|
||||
- os | lower in ["almalinux", "rhel8", "rhel9", "rhel10", "rocky"]
|
||||
- is_rhel | bool
|
||||
ansible.builtin.set_fact:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
changed_when: false
|
||||
@@ -107,8 +70,10 @@
|
||||
ansible_password: "{{ user_password }}"
|
||||
ansible_become_password: "{{ user_password }}"
|
||||
ansible_ssh_extra_args: "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||
changed_when: false
|
||||
|
||||
- name: Set connection for VMware
|
||||
when: hypervisor == "vmware"
|
||||
ansible.builtin.set_fact:
|
||||
ansible_connection: vmware_tools
|
||||
changed_when: false
|
||||
|
||||
Reference in New Issue
Block a user