refactor(partitioning): split monolithic main.yml into focused task files
This commit is contained in:
38
roles/partitioning/tasks/_detect_sizing.yml
Normal file
38
roles/partitioning/tasks/_detect_sizing.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: Detect system memory for swap sizing
|
||||
when:
|
||||
- system_cfg.features.swap.enabled | bool
|
||||
- partitioning_vm_memory is not defined or (partitioning_vm_memory | float) <= 0
|
||||
- (system_cfg.memory | default(0) | float) <= 0
|
||||
block:
|
||||
- name: Read system memory
|
||||
ansible.builtin.command: awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo
|
||||
register: partitioning_memtotal_mb
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Set partitioning vm memory default
|
||||
ansible.builtin.set_fact:
|
||||
partitioning_vm_memory: "{{ (partitioning_memtotal_mb.stdout | default('4096') | int) | float }}"
|
||||
|
||||
- name: Set partitioning vm_size for physical installs
|
||||
when:
|
||||
- system_cfg.type == "physical"
|
||||
- partitioning_vm_size is not defined or (partitioning_vm_size | float) <= 0
|
||||
- install_drive | length > 0
|
||||
block:
|
||||
- name: Detect install drive size
|
||||
ansible.builtin.command: "lsblk -b -dn -o SIZE {{ install_drive }}"
|
||||
register: partitioning_disk_size_bytes
|
||||
changed_when: false
|
||||
|
||||
- name: Set partitioning vm_size from install drive size
|
||||
when:
|
||||
- partitioning_disk_size_bytes.stdout is defined
|
||||
- (partitioning_disk_size_bytes.stdout | trim | length) > 0
|
||||
ansible.builtin.set_fact:
|
||||
partitioning_vm_size: >-
|
||||
{{
|
||||
(partitioning_disk_size_bytes.stdout | trim | int / 1024 / 1024 / 1024)
|
||||
| round(2, 'floor')
|
||||
}}
|
||||
Reference in New Issue
Block a user