From 1688ead9c8726177f416c8f67459088804eaaaec Mon Sep 17 00:00:00 2001 From: mhorak Date: Thu, 14 Aug 2025 09:07:39 +0000 Subject: [PATCH] Update win-updates-troubleshooting.yaml --- win-updates-troubleshooting.yaml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/win-updates-troubleshooting.yaml b/win-updates-troubleshooting.yaml index 890ad3a..6a89bad 100644 --- a/win-updates-troubleshooting.yaml +++ b/win-updates-troubleshooting.yaml @@ -156,29 +156,24 @@ - (kb_numbers is not defined or kb_numbers | length == 0) # ---- Aggregate & publish facts to localhost for next play ---- - - name: Aggregate per-host patch failures and publish to localhost + - name: Collect failed hosts (no extract filter; safe default) run_once: true delegate_to: localhost delegate_facts: true set_fact: - failed_hosts_list: [] - - - name: Collect failed hosts (no extract filter) - run_once: true - delegate_to: localhost - delegate_facts: true - set_fact: - failed_hosts_list: "{{ failed_hosts_list + [item] }}" + failed_hosts_list: "{{ (failed_hosts_list | default([])) + [item] }}" loop: "{{ ansible_play_hosts_all }}" when: hostvars[item].patch_failed_host | default(false) - - name: Publish aggregate flags to localhost + - name: Publish aggregate flags to localhost (safe even if none failed) run_once: true delegate_to: localhost delegate_facts: true + vars: + _fails: "{{ hostvars['localhost'].failed_hosts_list | default([]) }}" set_fact: - any_patch_failed: "{{ (failed_hosts_list | length) > 0 }}" - failed_hosts_csv: "{{ failed_hosts_list | join(', ') if failed_hosts_list | length > 0 else 'None' }}" + any_patch_failed: "{{ (_fails | length) > 0 }}" + failed_hosts_csv: "{{ _fails | join(', ') if (_fails | length) > 0 else 'None' }}" # ------------------------------------------------------------------------------