237 lines
8.4 KiB
YAML
237 lines
8.4 KiB
YAML
---
|
|
- name: Validate core variables
|
|
ansible.builtin.assert:
|
|
that:
|
|
- install_type is defined
|
|
- install_type in ["virtual", "physical"]
|
|
- hypervisor_cfg is defined
|
|
- hypervisor_cfg is mapping
|
|
- hypervisor_type is defined
|
|
- hypervisor_type in ["libvirt", "proxmox", "vmware", "xen", "none"]
|
|
- filesystem is defined
|
|
- filesystem in ["btrfs", "ext4", "xfs"]
|
|
- install_drive is defined
|
|
- install_drive | string | length > 0
|
|
- hostname is defined
|
|
- hostname | string | length > 0
|
|
fail_msg: Invalid core variables were specified, please check your inventory/vars.
|
|
quiet: true
|
|
|
|
- name: Validate install_type/hypervisor relationship
|
|
ansible.builtin.assert:
|
|
that:
|
|
- install_type == "physical" or hypervisor_type in ["libvirt", "proxmox", "vmware", "xen"]
|
|
fail_msg: "hypervisor must be one of: libvirt, proxmox, vmware, xen when install_type=virtual."
|
|
quiet: true
|
|
|
|
- name: Validate OS and version inputs
|
|
ansible.builtin.assert:
|
|
that:
|
|
- os is defined
|
|
- os in ["almalinux", "alpine", "archlinux", "debian", "fedora", "opensuse", "rhel", "rocky", "ubuntu", "ubuntu-lts", "void"]
|
|
- >-
|
|
os not in ["debian", "fedora", "rocky", "almalinux", "rhel"]
|
|
or (os_version is defined and (os_version | string | length) > 0)
|
|
- >-
|
|
os_version is not defined or (os_version | string | length) == 0
|
|
or (
|
|
os == "debian" and (os_version | string) in ["10", "11", "12", "13", "unstable"]
|
|
) or (
|
|
os == "fedora" and (os_version | string) in ["40", "41", "42", "43"]
|
|
) or (
|
|
os in ["rocky", "almalinux"]
|
|
and (os_version | string) is match("^(8|9|10)(\\.\\d+)?$")
|
|
) or (
|
|
os == "rhel"
|
|
and (os_version | string) is match("^(8|9|10)(\\.\\d+)?$")
|
|
) or (
|
|
os in ["alpine", "archlinux", "opensuse", "ubuntu", "ubuntu-lts", "void"]
|
|
)
|
|
fail_msg: "Invalid os/os_version specified. Please check README.md for supported values."
|
|
quiet: true
|
|
|
|
- name: Validate RHEL ISO requirement
|
|
ansible.builtin.assert:
|
|
that:
|
|
- os != "rhel" or (rhel_iso is defined and (rhel_iso | string | length) > 0)
|
|
fail_msg: "rhel_iso is required when os=rhel."
|
|
quiet: true
|
|
|
|
- name: Validate Proxmox hypervisor inputs
|
|
when:
|
|
- install_type == "virtual"
|
|
- hypervisor_type == "proxmox"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- hypervisor_cfg.url | string | length > 0
|
|
- hypervisor_cfg.username | string | length > 0
|
|
- hypervisor_cfg.password | string | length > 0
|
|
- hypervisor_cfg.node | string | length > 0
|
|
- hypervisor_cfg.storage | string | length > 0
|
|
- system_cfg.id | string | length > 0
|
|
- system_cfg.network | string | length > 0
|
|
fail_msg: "Missing required Proxmox inputs. Define hypervisor.(url,username,password,node,storage) and system.(id,network)."
|
|
quiet: true
|
|
|
|
- name: Validate VMware hypervisor inputs
|
|
when:
|
|
- install_type == "virtual"
|
|
- hypervisor_type == "vmware"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- hypervisor_cfg.url | string | length > 0
|
|
- hypervisor_cfg.username | string | length > 0
|
|
- hypervisor_cfg.password | string | length > 0
|
|
- hypervisor_cfg.datacenter | string | length > 0
|
|
- hypervisor_cfg.cluster | string | length > 0
|
|
- hypervisor_cfg.storage | string | length > 0
|
|
- system_cfg.network | string | length > 0
|
|
fail_msg: "Missing required VMware inputs. Define hypervisor.(url,username,password,datacenter,cluster,storage) and system.network."
|
|
quiet: true
|
|
|
|
- name: Validate Xen hypervisor inputs
|
|
when:
|
|
- install_type == "virtual"
|
|
- hypervisor_type == "xen"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- system_cfg.network | string | length > 0
|
|
fail_msg: "Missing required Xen inputs. Define system.network."
|
|
quiet: true
|
|
|
|
- name: Validate virtual installer ISO requirement
|
|
ansible.builtin.assert:
|
|
that:
|
|
- install_type == "physical" or (boot_iso is defined and (boot_iso | string | length) > 0)
|
|
fail_msg: "boot_iso is required when install_type=virtual."
|
|
quiet: true
|
|
|
|
- name: Validate firewall and feature flags
|
|
ansible.builtin.assert:
|
|
that:
|
|
- firewall_backend is defined
|
|
- firewall_backend in ["firewalld", "ufw"]
|
|
- firewall_toolkit is defined
|
|
- firewall_toolkit in ["iptables", "nftables"]
|
|
- firewall_enabled is defined
|
|
- motd_enabled is defined
|
|
- sudo_banner_enabled is defined
|
|
- luks_enabled is defined
|
|
- chroot_tool is defined
|
|
- chroot_tool in ["arch-chroot", "chroot", "systemd-nspawn"]
|
|
fail_msg: Invalid feature flags were specified, please check your inventory/vars.
|
|
quiet: true
|
|
|
|
- name: Validate system configuration exists
|
|
ansible.builtin.assert:
|
|
that:
|
|
- system_cfg is defined
|
|
- system_cfg is mapping
|
|
fail_msg: "system configuration is missing. Define system: {...}."
|
|
quiet: true
|
|
|
|
- name: Validate virtual system sizing
|
|
when: install_type == "virtual"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- system_cfg.cpus is defined and (system_cfg.cpus | int) > 0
|
|
- system_cfg.memory_mb is defined and (system_cfg.memory_mb | int) > 0
|
|
- system_cfg.disks is defined and (system_cfg.disks | length) > 0
|
|
- (system_cfg.disks[0].size | float) > 0
|
|
- (system_cfg.disks[0].size | float) >= 20
|
|
- >-
|
|
filesystem != "btrfs"
|
|
or (
|
|
(system_cfg.disks[0].size | float)
|
|
>= (
|
|
(
|
|
(system_cfg.memory_mb | float / 1024 >= 16.0)
|
|
| ternary(
|
|
(system_cfg.memory_mb | float / 2048),
|
|
[system_cfg.memory_mb | float / 1024, 4.0] | max
|
|
)
|
|
)
|
|
+ 5.5
|
|
)
|
|
)
|
|
fail_msg: "Invalid system sizing. Check system.cpus, system.memory_mb, and system.disks[0].size."
|
|
quiet: true
|
|
|
|
- name: Validate all virtual disks have a positive size
|
|
when: install_type == "virtual"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- item.size is defined
|
|
- (item.size | float) > 0
|
|
fail_msg: "Each system disk must have a positive size when install_type=virtual: {{ item | to_json }}"
|
|
quiet: true
|
|
loop: "{{ system_cfg.disks | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item | to_json }}"
|
|
|
|
- name: Validate primary disk mount is not used
|
|
when:
|
|
- system_cfg.disks is defined
|
|
- system_cfg.disks | length > 0
|
|
ansible.builtin.assert:
|
|
that:
|
|
- (system_cfg.disks[0].mount | default('') | string | trim) == ''
|
|
fail_msg: "system.disks[0].mount must be empty; use system.disks[1:] for additional mounts."
|
|
quiet: true
|
|
|
|
- name: Validate disk mountpoint inputs
|
|
vars:
|
|
system_disk_mounts: >-
|
|
{{
|
|
(system_cfg.disks | default([]))
|
|
| map(attribute='mount')
|
|
| map('string')
|
|
| map('trim')
|
|
| reject('equalto', '')
|
|
| list
|
|
}}
|
|
ansible.builtin.assert:
|
|
that:
|
|
- system_disk_mounts | length == (system_disk_mounts | unique | list | length)
|
|
fail_msg: "Duplicate disk mountpoints found in system.disks."
|
|
quiet: true
|
|
|
|
- name: Validate disk mount definitions
|
|
when: system_cfg.disks is defined
|
|
vars:
|
|
reserved_mounts:
|
|
- /boot
|
|
- /boot/efi
|
|
- /home
|
|
- /swap
|
|
- /var
|
|
- /var/cache/pacman/pkg
|
|
- /var/log
|
|
- /var/log/audit
|
|
disk_mount: "{{ (item.mount | default('') | string) | trim }}"
|
|
disk_fstype: "{{ (item.fstype | default('') | string) | trim }}"
|
|
disk_device: "{{ (item.device | default('') | string) | trim }}"
|
|
disk_size: "{{ item.size | default(0) }}"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- disk_mount == "" or disk_mount.startswith("/")
|
|
- disk_mount == "" or disk_mount != "/"
|
|
- disk_mount == "" or disk_mount not in reserved_mounts
|
|
- disk_mount == "" or disk_fstype in ["btrfs", "ext4", "xfs"]
|
|
- disk_mount == "" or install_type == "virtual" or (disk_device | length) > 0
|
|
- disk_mount == "" or install_type != "virtual" or (disk_size | float) > 0
|
|
fail_msg: "Invalid system disk entry: {{ item | to_json }}"
|
|
quiet: true
|
|
loop: "{{ system_cfg.disks }}"
|
|
loop_control:
|
|
label: "{{ item | to_json }}"
|
|
|
|
- name: Validate static IP requirements
|
|
when: system_cfg.ip is defined and (system_cfg.ip | string | length) > 0
|
|
ansible.builtin.assert:
|
|
that:
|
|
- system_cfg.prefix is defined
|
|
- (system_cfg.prefix | int) > 0
|
|
fail_msg: "system.prefix is required when system.ip is set."
|
|
quiet: true
|