a
This commit is contained in:
@@ -46,31 +46,37 @@
|
||||
winre_parts: "{{ [winre_parts] }}"
|
||||
when: winre_parts is mapping
|
||||
|
||||
# --- threshold (MiB) -> bytes
|
||||
# Thresholds
|
||||
- name: Set Recovery size threshold
|
||||
ansible.builtin.set_fact:
|
||||
recovery_threshold_mib: 500
|
||||
recovery_threshold_bytes: "{{ 500 * 1024 * 1024 }}"
|
||||
changed_when: false
|
||||
|
||||
# Smallest Recovery partition on this host (if any)
|
||||
- name: Compute smallest Recovery partition size (bytes)
|
||||
# Build a list of sizes as INTS
|
||||
- name: Extract recovery sizes (bytes → ints)
|
||||
ansible.builtin.set_fact:
|
||||
recovery_min_bytes: "{{ winre_parts | map(attribute='SizeBytes') | map('int') | list | min }}"
|
||||
when: winre_parts | length > 0
|
||||
recovery_sizes_bytes: "{{ winre_parts | map(attribute='SizeBytes') | map('int') | list }}"
|
||||
changed_when: false
|
||||
|
||||
# Fail this host if it has a Recovery partition smaller than 500 MiB
|
||||
# Compute smallest size (bytes)
|
||||
- name: Compute smallest Recovery partition size (bytes)
|
||||
ansible.builtin.set_fact:
|
||||
recovery_min_bytes: "{{ recovery_sizes_bytes | min }}"
|
||||
when: recovery_sizes_bytes | length > 0
|
||||
changed_when: false
|
||||
|
||||
# Fail this host if smallest Recovery partition < 500 MiB
|
||||
- name: Enforce minimum Recovery partition size
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
Recovery partition too small on {{ inventory_hostname }}:
|
||||
smallest={{ (recovery_min_bytes / 1024 / 1024) | round(2) }} MiB,
|
||||
required >= {{ recovery_threshold_mib }} MiB.
|
||||
smallest={{ ((recovery_min_bytes | int) / 1048576.0) | round(2) }} MiB,
|
||||
required >= {{ recovery_threshold_mib | int }} MiB.
|
||||
Details: {{ winre_parts }}
|
||||
when:
|
||||
- winre_parts | length > 0
|
||||
- recovery_min_bytes < recovery_threshold_bytes
|
||||
- recovery_sizes_bytes | length > 0
|
||||
- (recovery_min_bytes | int) < (recovery_threshold_bytes | int)
|
||||
|
||||
- name: Show Recovery partition sizes
|
||||
ansible.builtin.debug:
|
||||
|
||||
Reference in New Issue
Block a user