From c9a15dfccfefb098d96dbd7d309983384b5e4138 Mon Sep 17 00:00:00 2001 From: Sandwich Date: Thu, 31 Oct 2024 17:32:27 +0100 Subject: [PATCH] improve logical volume size calculation --- roles/cleanup/tasks/main.yml | 7 ----- roles/partitioning/tasks/main.yml | 46 +++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/roles/cleanup/tasks/main.yml b/roles/cleanup/tasks/main.yml index 0bf13cd..258517d 100644 --- a/roles/cleanup/tasks/main.yml +++ b/roles/cleanup/tasks/main.yml @@ -1,11 +1,4 @@ --- -- name: Unmount /mnt recursively - when: os not in ['rhel8', 'rhel9'] - become: false - ansible.builtin.command: umount -l /mnt - changed_when: result.rc == 0 - register: result - - name: Setup Cleanup when: hypervisor == "proxmox" delegate_to: localhost diff --git a/roles/partitioning/tasks/main.yml b/roles/partitioning/tasks/main.yml index 8668434..e34b764 100644 --- a/roles/partitioning/tasks/main.yml +++ b/roles/partitioning/tasks/main.yml @@ -43,15 +43,43 @@ size: "{{ item.size }}" state: present loop: - - { lv: root, size: "{{ [(vm_size | float) - 0.5 - (((vm_memory | float / 1024) >= 16.0) - | ternary((vm_memory | float / 1024 / 2) | int, 4)) - 7.5, 1] | max | float - | round(1) | string + 'G' }}" } - - { lv: swap, size: "{{ ((vm_memory | float / 1024 >= 16.0) | ternary((vm_memory | float / 2048) - | int, [vm_memory | float / 1024, 4.0] | max)) | string + 'G' }}" } - - { lv: home, size: "2G" } - - { lv: var, size: "2G" } - - { lv: var_log, size: "2G" } - - { lv: var_log_audit, size: "1.5G" } + - lv: root + size: >- + {{ ((cis | lower == 'true') | ternary( + (((vm_size | float - ((vm_memory | float / 1024 >= 16.0) | ternary( + (vm_memory | float / 2048) | int, + [vm_memory | float / 1024, 4.0] | max + )) - 0.5 - 7.5) > 12.0) | ternary( + (vm_size | float * 0.4) | round(0, 'ceil'), + vm_size | float - ((vm_memory | float / 1024 >= 16.0) | ternary( + (vm_memory | float / 2048) | int, + [vm_memory | float / 1024, 4.0] | max + )) - 0.5 - 7.5 + )), + vm_size | float - ((vm_memory | float / 1024 >= 16.0) | ternary( + (vm_memory | float / 2048) | int, + [vm_memory | float / 1024, 4.0] | max + )) - 0.5 + )) | string + 'G' }} + + - lv: swap + size: >- + {{ ((vm_memory | float / 1024 >= 16.0) | ternary( + (vm_memory | float / 2048) | int, + [vm_memory | float / 1024, 4.0] | max + )) | string + 'G' }} + + - lv: home + size: "2G" + + - lv: var + size: "2G" + + - lv: var_log + size: "2G" + + - lv: var_log_audit + size: "1.5G" - name: Create filesystems block: