improve logical volume size calculation

This commit is contained in:
Sandwich 2024-10-31 17:32:27 +01:00
parent f83a9ebd67
commit c9a15dfccf
2 changed files with 37 additions and 16 deletions

View File

@ -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

View File

@ -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: