From 897eab8d04e2286bfe0f55b6223d50798b303a88 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Tue, 17 Apr 2018 11:39:45 +1000 Subject: [PATCH] win_updates: fix when failed is not present in output (#38856) (#38857) (cherry picked from commit f1c16438c1bc87ca1b4d2b6c8b5ee5be57739efb) --- lib/ansible/plugins/action/win_updates.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/action/win_updates.py b/lib/ansible/plugins/action/win_updates.py index 09d51c2598d..766ff496993 100644 --- a/lib/ansible/plugins/action/win_updates.py +++ b/lib/ansible/plugins/action/win_updates.py @@ -189,10 +189,12 @@ class ActionModule(ActionBase): # if the module failed to run at all then changed won't be populated # so we just return the result as is # https://github.com/ansible/ansible/issues/38232 - if result['failed']: + failed = result.get('failed', False) + if "updates" not in result.keys() or failed: + result['failed'] = True return result - changed = result['changed'] + changed = result.get('changed', False) updates = result.get('updates', dict()) filtered_updates = result.get('filtered_updates', dict()) found_update_count = result.get('found_update_count', 0) @@ -241,7 +243,7 @@ class ActionModule(ActionBase): result.pop('msg', None) # rerun the win_updates module after the reboot is complete result = self._run_win_updates(new_module_args, task_vars) - if result['failed']: + if result.get('failed', False): return result result_updates = result.get('updates', dict())