diff --git a/www-windows-check-free-disk-space.yaml b/www-windows-check-free-disk-space.yaml index a4e69a6..1b1c4b4 100644 --- a/www-windows-check-free-disk-space.yaml +++ b/www-windows-check-free-disk-space.yaml @@ -20,25 +20,20 @@ when: - freediskspace.stdout | trim | float < 20 - - name: Gather disk & partition facts - community.windows.win_disk_facts: + - name: Find Recovery partitions and sizes (MB) + ansible.windows.win_powershell: + script: | + $guid = '{DE94BBA4-06D1-4D40-A16A-BFD50179D6AC}' + $parts = Get-Partition | + Where-Object { + $_.GptType -eq $guid -or $_.Type -eq 'Recovery' -or $_.Type -eq 'Unknown' + } | + Select-Object DiskNumber, PartitionNumber, + @{n='SizeMB';e={[math]::Round($_.Size/1MB,2)}}, + GptType, Type + $parts | ConvertTo-Json -Compress + register: winre_parts - - name: Show Recovery partition sizes (handles GPT + MBR) + - name: Show results ansible.builtin.debug: - msg: >- - Recovery partition (part {{ item.number|default('n/a') }}, offset {{ item.offset }}) - size: {{ item.size | filesizeformat }} - loop: >- - {{ - ( - ansible_facts.disks | map(attribute='partitions') | list | flatten - | selectattr('gpt_type','defined') - | selectattr('gpt_type','search','(?i)de94bba4-06d1-4d40-a16a-bfd50179d6ac') - ) - + - ( - ansible_facts.disks | map(attribute='partitions') | list | flatten - | selectattr('mbr_type','defined') - | selectattr('mbr_type','equalto',27) - ) - }} + var: winre_parts.output | from_json \ No newline at end of file