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: Windows updates processing is stopped if any update fails #22

Closed
jborean93 opened this issue Mar 11, 2020 · 6 comments · Fixed by #225
Closed

win_updates: Windows updates processing is stopped if any update fails #22

jborean93 opened this issue Mar 11, 2020 · 6 comments · Fixed by #225

Comments

@jborean93
Copy link
Collaborator

From @ramon-garcia on Dec 13, 2018 10:34

SUMMARY

When updating windows with win_updates, with the reboot option, the intention is that the system is updated and rebooted as many times as necessary.

But, if after some update, any of them fails,the processing is stopped.

After reading the source, this looks like a simple bug. In the source file lib/ansible/plugins/action/win_updates.py

    # 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
    failed = result.get('failed', False)
    if ("updates" not in result.keys() and self._task.async_val == 0) or failed:
        result['failed'] = True
        return result

The problem is in the conditional. For fixing issue #38232 , in the case failed the processing is stopped.
I changed the condition to:

if ("updates" not in result.keys() and self._task.async_val == 0) or \
            (failed and not (reboot and result.get('reboot_required', False))):

So that, if reboots are requested, and the last update attempt returned that reboot is needed, then go on.

Another similar case, if the update request fails because a reboot is pending. The flow should not stop.

Hope this helps.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_updates

ANSIBLE VERSION
2.7.4
CONFIGURATION

OS / ENVIRONMENT

This is Ansible runing under Centos 7. The target is Windows Server.

STEPS TO REPRODUCE

run

ansible -m win_updates --args 'reboot=true' [some server]

EXPECTED RESULTS

The server should install all updates including rebooting as many times as necessary.

ACTUAL RESULTS

The process stops as soon as one update fails.

Copied from original issue: ansible/ansible#49874

@jborean93
Copy link
Collaborator Author

From @ramon-garcia on Jan 16, 2019 16:43

ping

@jborean93
Copy link
Collaborator Author

From @ramon-garcia on Jan 16, 2019 16:43

!component lib/ansible/plugins/action/win_updates.py

@jborean93
Copy link
Collaborator Author

From @dagwieers on Jan 16, 2019 16:59

@ramon-garcia Why not create the require PR directly. It makes it easier to assess the code and approve.

@jborean93
Copy link
Collaborator Author

From @ramon-garcia on Jan 18, 2019 16:53

ok. I will try to place a pull request

@jborean93
Copy link
Collaborator Author

From @ramon-garcia on May 12, 2019 22:45

ping

@jborean93
Copy link
Collaborator Author

From @ramon-garcia on Dec 09, 2019 12:57

ping.

Is there any way I can help with testing?

Perhaps placing a virtual machine in a public cloud?

@jborean93 jborean93 changed the title Windows updates processing is stopped if any update fails win_updates: Windows updates processing is stopped if any update fails Mar 12, 2020
@jborean93 jborean93 mentioned this issue May 21, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant