This commit is contained in:
2025-08-14 16:41:50 +02:00
parent b76a10b645
commit 0198b3b2e2

View File

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