Skip to content

Commit

Permalink
win_updates: backport 2.5 handle failure on module load (#38498)
Browse files Browse the repository at this point in the history
* win_updates: handle if module failed to run (#38363)

(cherry picked from commit ccc56e1)

* Added changelog fragment
  • Loading branch information
jborean93 committed Apr 9, 2018
1 parent 38a13f4 commit 9bb2a36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/win_updates_handle-module-failures.yaml
@@ -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
8 changes: 8 additions & 0 deletions lib/ansible/plugins/action/win_updates.py
Expand Up @@ -186,6 +186,12 @@ def run(self, tmp=None, task_vars=None):
new_module_args.pop('reboot_timeout', None)
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']
updates = result.get('updates', dict())
filtered_updates = result.get('filtered_updates', dict())
Expand Down Expand Up @@ -235,6 +241,8 @@ def run(self, tmp=None, task_vars=None):
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']:
return result

result_updates = result.get('updates', dict())
result_filtered_updates = result.get('filtered_updates', dict())
Expand Down

0 comments on commit 9bb2a36

Please sign in to comment.