diff --git a/.ansible-lint b/.ansible-lint index d4f0d78..f25316d 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,2 +1,4 @@ skip_list: - run-once +exclude_paths: + - roles/global_defaults/defaults/main.yml diff --git a/main.yml b/main.yml index 10eb0bd..75feea9 100644 --- a/main.yml +++ b/main.yml @@ -35,16 +35,44 @@ 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"]) + - >- + 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)) + - >- + 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" diff --git a/roles/partitioning/tasks/main.yml b/roles/partitioning/tasks/main.yml index cdd6eb1..5609f6a 100644 --- a/roles/partitioning/tasks/main.yml +++ b/roles/partitioning/tasks/main.yml @@ -258,6 +258,58 @@ - name: Create LVM logical volumes when: cis_enabled or item.lv not in ['home', 'var', 'var_log', 'var_log_audit'] + vars: + partitioning_lvm_swap_target_gb: >- + {{ + ( + ((partitioning_vm_memory_effective | float / 1024) > 16.0) + | ternary( + (partitioning_vm_memory_effective | float / 2048) | int, + (partitioning_vm_memory_effective | float / 1024) + ) + ) | float + }} + partitioning_lvm_available_gb: >- + {{ + ( + (partitioning_vm_size_effective | float) + - (partitioning_reserved_gb | float) + - (cis_enabled | ternary(7.5, 0)) + - partitioning_lvm_swap_target_gb + ) | float + }} + partitioning_lvm_root_gb: >- + {{ + [ + ( + ((partitioning_lvm_available_gb | float) < 4) + | ternary( + 4, + ( + ((partitioning_lvm_available_gb | float) > 12) + | ternary( + ((partitioning_vm_size_effective | float) * 0.4) + | round(0, 'ceil'), + partitioning_lvm_available_gb + ) + ) + ) + ), + 4 + ] | max + }} + partitioning_lvm_swap_gb: >- + {{ + ((partitioning_lvm_available_gb | float) < 4) + | ternary( + ( + (partitioning_lvm_available_gb | float) + + (partitioning_lvm_swap_target_gb | float) + - 4 + ), + partitioning_lvm_swap_target_gb + ) + }} community.general.lvol: vg: sys lv: "{{ item.lv }}" @@ -265,27 +317,9 @@ state: present loop: - lv: root - size: >- - {{ [(((((partitioning_vm_size_effective | float) - (partitioning_reserved_gb | float) - ((cis_enabled) | ternary(7.5, 0)) - (((partitioning_vm_memory_effective | float / 1024) > 16.0) - | ternary(((partitioning_vm_memory_effective | float / 2048) | int), (partitioning_vm_memory_effective | float / 1024)))) < 4) - | ternary(4,((((partitioning_vm_size_effective | float) - (partitioning_reserved_gb | float) - ((cis_enabled) | ternary(7.5, 0)) - - (((partitioning_vm_memory_effective | float / 1024) > 16.0) - | ternary( - ((partitioning_vm_memory_effective | float / 2048) | int), - (partitioning_vm_memory_effective | float / 1024) - ))) - > 12) - | ternary(((partitioning_vm_size_effective | float) * 0.4) | round(0, 'ceil'),((partitioning_vm_size_effective | float) - (partitioning_reserved_gb | float) - ((cis_enabled) - | ternary(7.5, 0)) - (((partitioning_vm_memory_effective | float / 1024) > 16.0) - | ternary(((partitioning_vm_memory_effective | float / 2048) | int), (partitioning_vm_memory_effective | float / 1024))))))))), 4 ] | max | string + - 'G' }} + size: "{{ partitioning_lvm_root_gb | string + 'G' }}" - lv: swap - size: >- - {{ ((((partitioning_vm_size_effective | float) - (partitioning_reserved_gb | float) - ((cis_enabled) | ternary(7.5, 0))) - (((partitioning_vm_memory_effective | float / 1024) > 16.0) - | ternary(((partitioning_vm_memory_effective | float / 2048) | int), (partitioning_vm_memory_effective | float / 1024)))) < 4) - | ternary((((partitioning_vm_size_effective | float) - (partitioning_reserved_gb | float) - ((cis_enabled) | ternary(7.5, 0))) - 4), (((partitioning_vm_memory_effective | float / 1024) - > 16.0) - | ternary(((partitioning_vm_memory_effective | float / 2048) | int), (partitioning_vm_memory_effective | float / 1024)))) | string + 'G' }} + size: "{{ partitioning_lvm_swap_gb | string + 'G' }}" - lv: home size: "{{ ([([(((partitioning_vm_size_effective | float) - 20) * 0.1), 2] | max), 20] | min) | string + 'G' }}" - {lv: var, size: "2G"}