From ad228cb0684b67fce5d099b51bb90ff54923f45d Mon Sep 17 00:00:00 2001 From: "mhorak@totalservice.cz" Date: Thu, 14 Aug 2025 16:31:40 +0200 Subject: [PATCH] pridan pozadavek na rec. partition alespon 500MB --- www-windows-check-free-disk-space.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/www-windows-check-free-disk-space.yaml b/www-windows-check-free-disk-space.yaml index f914899..638eb4e 100644 --- a/www-windows-check-free-disk-space.yaml +++ b/www-windows-check-free-disk-space.yaml @@ -46,6 +46,32 @@ winre_parts: "{{ [winre_parts] }}" when: winre_parts is mapping + # --- threshold (MiB) -> bytes + - 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) + ansible.builtin.set_fact: + recovery_min_bytes: "{{ (winre_parts | map(attribute='SizeBytes') | list) | min }}" + when: winre_parts | length > 0 + changed_when: false + + # Fail this host if it has a Recovery partition smaller than 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. + Details: {{ winre_parts }} + when: + - winre_parts | length > 0 + - recovery_min_bytes < recovery_threshold_bytes + - name: Show Recovery partition sizes ansible.builtin.debug: msg: "Disk {{ item.DiskNumber }}, Part {{ item.PartitionNumber }}, Size: {{ item.SizeMB }} MB ({{ item.SizeBytes }} bytes)"