win_updates: backport 2.5 handle failure on module load (#38498)

* win_updates: handle if module failed to run (#38363)

(cherry picked from commit ccc56e138a)

* Added changelog fragment
pull/37125/merge
Jordan Borean 7 years ago committed by GitHub
parent 38a13f41cd
commit 9bb2a36289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- win_updates - handle if the module fails to load and return the error message
https://github.com/ansible/ansible/pull/38363

@ -186,6 +186,12 @@ class ActionModule(ActionBase):
new_module_args.pop('reboot_timeout', None) new_module_args.pop('reboot_timeout', None)
result = self._run_win_updates(new_module_args, task_vars) result = self._run_win_updates(new_module_args, task_vars)
# 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']:
return result
changed = result['changed'] changed = result['changed']
updates = result.get('updates', dict()) updates = result.get('updates', dict())
filtered_updates = result.get('filtered_updates', dict()) filtered_updates = result.get('filtered_updates', dict())
@ -235,6 +241,8 @@ class ActionModule(ActionBase):
result.pop('msg', None) result.pop('msg', None)
# rerun the win_updates module after the reboot is complete # rerun the win_updates module after the reboot is complete
result = self._run_win_updates(new_module_args, task_vars) result = self._run_win_updates(new_module_args, task_vars)
if result['failed']:
return result
result_updates = result.get('updates', dict()) result_updates = result.get('updates', dict())
result_filtered_updates = result.get('filtered_updates', dict()) result_filtered_updates = result.get('filtered_updates', dict())

Loading…
Cancel
Save