# installing windows updates on windows hosts

**URL:** <https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [May 13, 2020, 10:37pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928 "2020-05-13T22:37:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 13, 2020, 10:37pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/1 "2020-05-13T22:37:39Z")

</div>



---

<div class="post-metadata">

**Author:** ![harry\_devine](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/harry_devine/32/5293_2.png) [@harry\_devine](https://forum.ansible.com/u/harry_devine)\
**Post date:** [May 13, 2020, 10:39pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/2 "2020-05-13T22:39:47Z")

</div>

Your “hosts” line needs to be before the - name line.

Harry

---

<div class="post-metadata">

**Author:** ![David\_Foley](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@David\_Foley](https://forum.ansible.com/u/David_Foley)\
**Post date:** [May 13, 2020, 10:44pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/3 "2020-05-13T22:44:46Z")

</div>

Also appears you are missing the Tasks: element in your playbook

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 13, 2020, 10:56pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/4 "2020-05-13T22:56:13Z")

</div>

change some indentation and it went through but still getting errors

> **(attachments)**
>
> ![Screen Shot 2020-05-13 at 3.55.11 PM.png](https://us1.discourse-cdn.com/ansible/original/2X/d/d47b3d10028515c34ca9a434ce3c5f6ce5adb9d4.png)

---

<div class="post-metadata">

**Author:** ![David\_Foley](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@David\_Foley](https://forum.ansible.com/u/David_Foley)\
**Post date:** [May 13, 2020, 11:05pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/5 "2020-05-13T23:05:16Z")

</div>

Again you seem to be missing vaules

reboot: yes  
When: """

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 14, 2020, 4:49pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/6 "2020-05-14T16:49:53Z")

</div>

I am not sure what it should be

I logged everything to a file and doesnt look like any updates but still getting this error

TASK [Reboot host if required] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [10.50.1.231]: FAILED! =\> {“changed”: false, “msg”: “Invalid options for win\_reboot: when”}

log on my win host:

2020-05-14 09:47:08Z WUA is available in current logon process, running natively  
2020-05-14 09:47:08Z Creating Windows Update session…  
2020-05-14 09:47:08Z Create Windows Update searcher…  
2020-05-14 09:47:08Z Setting the Windows Update Agent source catalog…  
2020-05-14 09:47:08Z Requested search source is ‘default’  
2020-05-14 09:47:08Z Search source set to ‘default’ (ServerSelection = 0)  
2020-05-14 09:47:08Z Searching for updates to install  
2020-05-14 09:47:11Z Found 0 updates  
2020-05-14 09:47:11Z Creating update collection…  
2020-05-14 09:47:11Z Calculating pre-install reboot requirement…  
2020-05-14 09:47:11Z Native job completed with output:  
Name Value

* * *

updates {}  
found\_update\_count 0  
changed False  
reboot\_required False  
installed\_update\_count 0  
filtered\_updates {}

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 14, 2020, 4:53pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/7 "2020-05-14T16:53:35Z")

</div>

Just found out when I run windows update manually on the machine, there were 3 updates that ansible didnt report back?

why is that

> **(attachments)**
>
> ![Screen Shot 2020-05-14 at 9.53.23 AM.png](https://us1.discourse-cdn.com/ansible/original/2X/f/f7e726eb58d4cb0a5fc2d7e1d5e4c29a250aadfd.png)

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [May 14, 2020, 8:52pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/8 "2020-05-14T20:52:10Z")

</div>

> TASK [Reboot host if required] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> fatal: [10.50.1.231]: FAILED! =\> {“changed”: false, “msg”: “Invalid options for win\_reboot: when”}

I can’t see you task but this sounds like your when clause is not indented correctly. You have it as a module option for win\_reboot when it should be on the same indentation as the module name.

> Just found out when I run windows update manually on the machine, there were 3 updates that ansible didnt report back?

From your screenshot it indicated those updates are only available through the public Windows Update catalogue and not your org’s WSUS catalog. The win\_updates module defaults to whatever the OS settings are so if you have a WSUS server configured it will only look there by default. In Ansible 2.8 and newer you can use the ‘server\_selection’ option as documented [1] to force win\_updates to check the public Windows update catalog and not the configured WSUS server.

[1] - [https://docs.ansible.com/ansible/latest/modules/win\_updates\_module.html](https://docs.ansible.com/ansible/latest/modules/win_updates_module.html)

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 14, 2020, 10:13pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/9 "2020-05-14T22:13:34Z")

</div>

nice thank you.

Do I need to specify the win\_reboot module?

here is my playbook

---

<div class="post-metadata">

**Author:** ![Tony\_Wong](https://avatars.discourse-cdn.com/v4/letter/t/3ab097/32.png) [@Tony\_Wong](https://forum.ansible.com/u/Tony_Wong)\
**Post date:** [May 14, 2020, 10:40pm UTC](https://forum.ansible.com/t/installing-windows-updates-on-windows-hosts/32928/10 "2020-05-14T22:40:33Z")

</div>

I got 2 updates installed on the windows host. but in my task it just errored out after the host rebooted. should i be doing something to my playbook here?

> **(attachments)**
>
> ![Screen Shot 2020-05-14 at 3.37.53 PM.png](https://us1.discourse-cdn.com/ansible/original/2X/3/3fc2d76f29bce38d1c9f118ec3bdc49389a148c7.png)
