From 396d802dc3f7e5234164671e9b0ba8ea33aaa07e Mon Sep 17 00:00:00 2001 From: Sandwich Date: Fri, 2 Jan 2026 16:08:36 +0100 Subject: [PATCH] Enable full-disk LVM root sizing --- README.md | 1 + roles/partitioning/defaults/main.yml | 1 + roles/partitioning/tasks/main.yml | 30 ++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a4fe276..10267e8 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ Use these only when you need to override the default layout logic. | `partitioning_boot_size_mib` | `/boot` size in MiB when a separate boot is used. | `1024` | | `partitioning_separate_boot` | Force a separate `/boot` partition. | `true` | | `partitioning_boot_fs_fstype` | Filesystem for `/boot` when separate. | `ext4` | +| `partitioning_use_full_disk` | Use remaining LVM space for the root volume. | `true` | To protect sensitive information, such as passwords, API keys, and other confidential variables (e.g., `hypervisor_password`), **it is recommended to use Ansible Vault**. diff --git a/roles/partitioning/defaults/main.yml b/roles/partitioning/defaults/main.yml index 6d972c3..4a313f9 100644 --- a/roles/partitioning/defaults/main.yml +++ b/roles/partitioning/defaults/main.yml @@ -22,6 +22,7 @@ partitioning_efi_size_mib: 512 partitioning_efi_start_mib: 1 partitioning_efi_end_mib: "{{ (partitioning_efi_start_mib | int) + (partitioning_efi_size_mib | int) }}" partitioning_boot_size_mib: 1024 +partitioning_use_full_disk: true partitioning_separate_boot: >- {{ (partitioning_luks_enabled | bool) diff --git a/roles/partitioning/tasks/main.yml b/roles/partitioning/tasks/main.yml index 5609f6a..420cd38 100644 --- a/roles/partitioning/tasks/main.yml +++ b/roles/partitioning/tasks/main.yml @@ -278,7 +278,11 @@ - partitioning_lvm_swap_target_gb ) | float }} - partitioning_lvm_root_gb: >- + partitioning_lvm_home_gb: >- + {{ + ([([(((partitioning_vm_size_effective | float) - 20) * 0.1), 2] | max), 20] | min) + }} + partitioning_lvm_root_default_gb: >- {{ [ ( @@ -310,6 +314,28 @@ partitioning_lvm_swap_target_gb ) }} + partitioning_lvm_root_full_gb: >- + {{ + [ + ( + (partitioning_vm_size_effective | float) + - (partitioning_reserved_gb | float) + - (partitioning_lvm_swap_gb | float) + - ( + (partitioning_lvm_home_gb | float) + 5.5 + if cis_enabled + else 0 + ) + ), + 4 + ] | max | round(2, 'floor') + }} + partitioning_lvm_root_gb: >- + {{ + partitioning_lvm_root_full_gb + if partitioning_use_full_disk | bool + else partitioning_lvm_root_default_gb + }} community.general.lvol: vg: sys lv: "{{ item.lv }}" @@ -321,7 +347,7 @@ - lv: swap size: "{{ partitioning_lvm_swap_gb | string + 'G' }}" - lv: home - size: "{{ ([([(((partitioning_vm_size_effective | float) - 20) * 0.1), 2] | max), 20] | min) | string + 'G' }}" + size: "{{ partitioning_lvm_home_gb | string + 'G' }}" - {lv: var, size: "2G"} - {lv: var_log, size: "2G"} - {lv: var_log_audit, size: "1.5G"}