Hello guys:
I’m trying to patch my Windows servers by using an until loop, so Ansible can keep patching and rebooting while needed. This is my code:
- name: Apply patches
win_updates:
category_names: - SecurityUpdates
- CriticalUpdates
- UpdateRollups
reboot: yes
reboot_timeout: 2400
register: updates
vars:
ansible_winrm_operation_timeout_sec: 120
ansible_winrm_read_timeout_sec: 150
failed_when:
updates.failed_update_count is defined and
updates.failed_update_count > 0 and
1 == 2
until: updates.msg is not defined and updates.installed_update_count == 0
retries: 10
I don’t know how many times Windows will require to be rebooted, so I asummed 10 as maximum. I noticed that Ansible rebooted once and continued patching. However, I started to see these messages:
TASK [os-update : Apply patches] *****************************************************************************************************************************************************
FAILED - RETRYING: Apply patches (10 retries left).
FAILED - RETRYING: Apply patches (9 retries left).
…
…
FAILED - RETRYING: Apply patches (1 retries left).
ok: [1.2.3.4]
PLAY RECAP **************************************************************************************************************************************************************************************
1.2.3.4 : ok=9 changed=0 unreachable=0 failed=0 skipped=6 rescued=0 ignored=0
I would guess no more patches were pending nor a reboot was required. However, when I open Windows Update on my server, I can see a message that states “Restart your PC to finish installing updates”. If I click on “Check for updates” to see if there are pending patches to be applied, I got a message “You’ll need to restart your PC to finish installing previous updates”.
As per my code, wasn’t Ansible suppossed to reboot the server if needed after patching? I confirm that it did reboot just once, but it seems Ansible isn’t detecting the need to reboot for the 2nd time.
How can I see the details of these “FAILED - RETRYING” notifications?
I hope someone can help me. Thanks in advance.