Read this in other languages:
English,
日本語,
Français
The win_updates
module is used to either check for or install Windows Updates. It uses the built-in Windows Update service, so you’ll still need a backend such as WSUS or the Microsoft Update servers. If your server’s Windows Update configuration is set to automatically download but not install, you can use this module to stage updates by telling it to search
for them. You can also whitelist or blacklist specific updates — for example, installing only one security update instead of all available updates.
To begin, we’ll create a new playbook, following a similar process to earlier exercises.
In Visual Studio Code:
iis_basic
.win_updates
and press Enter.win_updates
folder, select New File, name it site.yml
, and press Enter.You should now have an empty editor pane open for creating your playbook.
Edit site.yml
and add the following:
---
- hosts: windows
name: This is my Windows patching playbook
tasks:
- name: Install Windows Updates
win_updates:
category_names: ""
reboot: ""
Note
win_updates
: Checks for or installs updates.category_names
: Allows you to limit updates to specific categories via a variable.reboot
: Iftrue
, the remote host will reboot automatically when required, continuing the update process afterward. This is controlled via a survey variable so you can choose whether to reboot.
In automation controller:
Fill out the form:
Field | Value |
---|---|
Name | Windows Updates |
Description | (optional) |
Job Type | Run |
Inventory | Windows Workshop Inventory |
Project | Ansible Workshop Project |
Playbook | win_updates/site.yml |
Execution Environment | Default execution environment |
Credentials | Student Account |
Limit | windows |
Options | Enable fact storage |
Click Create job template.
Field | Value |
---|---|
Question | Which categories to install? |
Description | (Optional) |
Answer Variable Name | categories |
Answer Type | Multiple Choice (multiple select) |
Multiple Choice Options | Application Connectors CriticalUpdates DefinitionUpdates DeveloperKits FeaturePacks Guidance SecurityUpdates ServicePacks Tools UpdateRollups Updates |
Default option | CriticalUpdates SecurityUpdates |
Options | Required |
Click Create survey question to save the question.
Field | Value |
---|---|
Question | Reboot after install? |
Description | (Optional) |
Answer Variable Name | reboot_server |
Answer Type | Multiple Choice (single select) |
Multiple Choice Options | Yes No |
Default option | Yes |
Options | Required |
Click Create survey question.
Back on the job template page, toggle the Survey Enabled button.
You’ll be redirected to the job output page to watch progress in real-time.