39 lines
1.4 KiB
YAML
39 lines
1.4 KiB
YAML
---
|
|
- 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')
|
|
}}
|