- ubuntu/update-beszel.yaml: upgrade Beszel hub on killer2 and agents on ubuntu_servers - windows/update.yaml: install Windows Updates on [windows] group, reboot if needed - ansible.cfg: point vault_password_file at ~/.ansible/vault_pass Co-Authored-By: Claude Opus 5.5 <[email protected]>
54 lines
1.7 KiB
YAML
54 lines
1.7 KiB
YAML
---
|
|
# Install Windows Updates on the [windows] inventory group and reboot if required.
|
|
# Usage:
|
|
# ansible-playbook windows/update.yaml # install + reboot if needed
|
|
# ansible-playbook windows/update.yaml -e reboot=false # install only, report if reboot pending
|
|
# ansible-playbook windows/update.yaml -e search_only=true # just list available updates
|
|
|
|
- name: Update Windows servers
|
|
hosts: windows
|
|
gather_facts: false
|
|
vars:
|
|
reboot: true
|
|
search_only: false
|
|
update_categories:
|
|
- SecurityUpdates
|
|
- CriticalUpdates
|
|
- UpdateRollups
|
|
- DefinitionUpdates
|
|
- Updates
|
|
|
|
tasks:
|
|
- name: Check connectivity
|
|
ansible.windows.win_ping:
|
|
|
|
- name: Search for available updates
|
|
ansible.windows.win_updates:
|
|
category_names: "{{ update_categories }}"
|
|
state: searched
|
|
register: search
|
|
when: search_only | bool
|
|
|
|
- name: List available updates
|
|
ansible.builtin.debug:
|
|
msg: "{{ search.updates | dict2items | map(attribute='value.title') | list }}"
|
|
when: search_only | bool
|
|
|
|
- name: Install updates
|
|
ansible.windows.win_updates:
|
|
category_names: "{{ update_categories }}"
|
|
state: installed
|
|
reboot: "{{ reboot | bool }}"
|
|
reboot_timeout: 3600
|
|
register: result
|
|
when: not search_only | bool
|
|
|
|
- name: Report
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "Installed: {{ result.installed_update_count }}"
|
|
- "Failed: {{ result.failed_update_count | default(0) }}"
|
|
- "Reboot still required: {{ result.reboot_required }}"
|
|
- "{{ result.updates | dict2items | map(attribute='value.title') | list }}"
|
|
when: not search_only | bool
|