installing windows updates on windows hosts

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

Harry

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

change some indentation and it went through but still getting errors

(attachments)

Again you seem to be missing vaules

reboot: yes
When: """

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 {}

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)

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

nice thank you.

Do I need to specify the win_reboot module?

here is my playbook

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)