# Windows Server install updates playbook inconsistent

**URL:** <https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024>\
**Category:** Get Help\
**Tags:** windows, playbook\
**Created:** [November 20, 2024, 5:45pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024 "2024-11-20T17:45:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![andini](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@andini](https://forum.ansible.com/u/andini)\
**Post date:** [November 20, 2024, 5:45pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/1 "2024-11-20T17:45:07Z")

</div>

Hi everyone, I’m new to the forum so if there is a post like this already, I apologize.  
I have a few windows servers with no access to the internet, in workgroup, not join to the domain.  
My monthly process is to manually download the KBs from MS catalog and install them on those servers.  
Below is one of the tasks on my current playbook. The issue I am seeing, after the 1st reboot the job template (MOST TIMES) would never connect so it would never move to the 2nd task in my playbook. But there are also times when the playbook executes flowless all the way to the end without issues. I have played with various module with the same results. Any ideas/thoughts?

- name: Install 1st Update  
ansible.windows.win\_powershell:  
script: Add-WindowsPackage -Online -PackagePath:“{{ KB1 }}” -NoRestart -LogPath “C:\windows\temp\installkb1.log”  
tags: 1st

- name: Reboot (1st)  
ansible.windows.win\_reboot:  
reboot\_timeout: 600 # Wait up to 10 minutes for the system to reboot  
test\_command: echo “OK” # Ensure the system is back and accepting commands  
tags: 1stReboot

- name: Wait for SSH to be available after reboot (port 22)  
ansible.windows.win\_wait\_for:  
host: “{{ target\_host }}”  
port: 22 # SSH port  
state: started  
delay: 15 # Wait 15 seconds before checking  
timeout: 300 # Timeout after 5 minutes  
tags: WaitForReboot

---

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [November 20, 2024, 9:33pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/2 "2024-11-20T21:33:05Z")

</div>

I’m not clear whether the system is not rebooting or whether it’s rebooting and AWX does not detect it coming back. In either case, you have a 10 minute timer set. What happens when that expires. Do you get the failure you expect?

---

<div class="post-metadata">

**Author:** ![andini](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@andini](https://forum.ansible.com/u/andini)\
**Post date:** [November 21, 2024, 3:39am UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/3 "2024-11-21T03:39:45Z")

</div>

Hey Kevin,  
I should have explained little better.  
The win\_powershell module executes and the 1st KB gets installed.

The win\_reboot also starts which triggers the restart of the VM. The server reboots, comes back to the logging screen but the task will not complete, and it won’t move on to the next one, despite that I can ssh from another machine Ansible job still continues to run/hanging at the reboot task. I have seen the job template running at that state for maybe 7-9hours. I actually have to cancel the job.

After I posted this, I increase the verbosity to level 5 and I noticed that win\_reboot is trying to validate the reboot by trying to retrieve system boot time.  
Here are the last few lines of the log before canceling the job.

debug2: Received exit status from master 0  
ansible.windows.win\_reboot: last boot time: 133766322995000000  
ansible.windows.win\_reboot: last boot time check fail \_TestCommandFailure ‘boot time has not changed’, retrying in 1.96 seconds…  
Traceback (most recent call last):  
File “/usr/share/ansible/collections/ansible\_collections/ansible/windows/plugins/plugin\_utils/\_reboot.py”, line 392, in \_do\_until\_success\_or\_condition  
res = func(\*args, \*\*kwargs)  
File “/usr/share/ansible/collections/ansible\_collections/ansible/windows/plugins/plugin\_utils/\_reboot.py”, line 305, in \_check\_boot\_time  
raise \_TestCommandFailure(“boot time has not changed”)  
ansible\_collections.ansible.windows.plugins.plugin\_utils.\_reboot.\_TestCommandFailure: boot time has not changed  
ansible.windows.win\_reboot: attempting to get system boot time  
ansible.windows.win\_reboot: getting boot time  
ansible.windows.win\_reboot: running command: (Get-CimInstance -ClassName Win32\_OperatingSystem -Property LastBootUpTime).LastBootUpTime.ToFileTime()

---

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [November 21, 2024, 9:40pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/4 "2024-11-21T21:40:40Z")

</div>

I’m afraid I don’t use Ansible to patch Windows servers, so I’m not a lot of help on this. I might try to break this one task into a reboot that does not test for success, then a pause, and then another task that tests the server to see whether it’s up. Kind of clunky, but maybe more resilient?

---

<div class="post-metadata">

**Author:** ![DorBreger](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dorbreger/32/5141_2.png) [@DorBreger](https://forum.ansible.com/u/DorBreger)\
**Post date:** [November 22, 2024, 7:21pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/5 "2024-11-22T19:21:20Z")

</div>

Check whether both the AWX and the windows server are consistently synced via NTP.

---

<div class="post-metadata">

**Author:** ![andini](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@andini](https://forum.ansible.com/u/andini)\
**Post date:** [November 22, 2024, 8:22pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/6 "2024-11-22T20:22:52Z")

</div>

They are not. I will try to adjust the time and try it again. I will update once I am done.

---

<div class="post-metadata">

**Author:** ![DorBreger](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dorbreger/32/5141_2.png) [@DorBreger](https://forum.ansible.com/u/DorBreger)\
**Post date:** [November 22, 2024, 9:07pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/7 "2024-11-22T21:07:21Z")

</div>

The win\_reboot module works by checking whether the last reboot time is before or after the time of the ansible node. This is a common issue with it when NTP isn’t implemented.

---

<div class="post-metadata">

**Author:** ![andini](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@andini](https://forum.ansible.com/u/andini)\
**Post date:** [November 25, 2024, 6:33pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/9 "2024-11-25T18:33:50Z")

</div>

Thanks for the clue. After matching the time of the VMs with the time of AWX all the jobs, on 5 VMs completed successfully.

---

<div class="post-metadata">

**Author:** ![DorBreger](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dorbreger/32/5141_2.png) [@DorBreger](https://forum.ansible.com/u/DorBreger)\
**Post date:** [November 25, 2024, 6:57pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/10 "2024-11-25T18:57:35Z")

</div>

You are welcome. I noticed that when googling “ansible win\_reboot hangs” and the likes this solution isn’t found. Maybe you can edit the title of this post?

---

<div class="post-metadata">

**Author:** ![andini](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@andini](https://forum.ansible.com/u/andini)\
**Post date:** [November 25, 2024, 8:05pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/11 "2024-11-25T20:05:22Z")

</div>

I cannot figure out how to change the title. It’s probably because I marked it as solved.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [December 25, 2024, 8:06pm UTC](https://forum.ansible.com/t/windows-server-install-updates-playbook-inconsistent/11024/12 "2024-12-25T20:06:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
