Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win_updates: backport 2.5 handle failure on module load #38498

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/win_updates_handle-module-failures.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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