win_update updated

This commit is contained in:
abrown38 committed 2025-04-30 15:53:29 +01:00
1 parent f36bd67c5c
commit 4b74f26c01
4 files changed
+209 -29

No files matched your search

+57 -22
View File
@@ -1,30 +1,65 @@
---
- name: Update VM
tags: update_vm
- name: Install client VM updates and reboot as much as needed
block:
- name: Clear update cache
win_shell: |
UsoClient RefreshSettings
UsoClient ScanInstallWait
- name: Update Windows
- name: Install Windows updates (looped)
tags: update_windows
ansible.windows.win_updates:
category_names: '*'
skip_optional: true
category_names:
- CriticalUpdates
- DefinitionUpdates
- SecurityUpdates
- UpdateRollups
reboot: true
reboot_timeout: 3600
ignore_errors: true
register: update_result
retries: 5
delay: 30
until: update_result.reboot_required == false
- name: Update Windows (again)
- name: Wait for host to come back online
tags: update_windows
ansible.builtin.wait_for_connection:
timeout: 600
- name: Update all choco packages
win_command: choco upgrade all -y
tags: update_choco
- name: Update Start Menu Shortcuts in XML on remote Windows machines
tags: update_start_menu
block:
- name: Copy Python script to target machine
ansible.windows.win_template:
src: "{{ script_name }}"
dest: "{{ script_path }}"
force: true
- name: Copy current XML to backup location
win_copy:
remote_src: true
src: "{{ start_menu_xml }}"
dest: "{{ backup_xml }}"
- name: Run Python script on remote machine
win_command: python "{{ script_path }}.xml"
when: "inventory_hostname in groups['meta-type_client']|default([])"
- name: Install Server VM updates and reboot as much as needed
tags: update_windows
block:
- name: Install Windows updates (looped)
ansible.windows.win_updates:
category_names: '*'
category_names:
- CriticalUpdates
- DefinitionUpdates
- SecurityUpdates
- UpdateRollups
reboot: true
reboot_timeout: 3600
ignore_errors: true
register: update_result
retries: 5
delay: 30
until: update_result.reboot_required == false
- name: Logging action
vars:
ansible_connection: local
ansible.builtin.shell:
cmd: echo "Update {{ os_project }}-{{ ansible_hostname }} $(date '+%Y-%m-%d %H:%M:%S')" >> /deployments/{{ os_project }}-{{ win_project }}/action.log
delegate_to: localhost
- name: Wait for host to come back online
ansible.builtin.wait_for_connection:
timeout: 600
when: "inventory_hostname in groups['meta-type_server']"