Files
windows-ansible/ansible/roles/win_update/tasks/update.yml
T
2025-05-23 11:26:44 +01:00

71 lines
2.0 KiB
YAML

---
- name: Install all updates and reboot as many times as needed
tags: update_windows1
block:
- name: Install Windows updates (looped)
ansible.windows.win_updates:
category_names: '*'
reboot: true
register: update_result
retries: 5
delay: 30
until: update_result.reboot_required == false
- name: Wait for host to come back online
ansible.builtin.wait_for_connection:
timeout: 600
- name: Install all Windows updates and reboot if required
tags: update_windows
block:
- name: Install Windows updates (no auto reboot)
ansible.windows.win_updates:
category_names: '*'
reboot: false
register: update_result
- name: Reboot the machine if updates require it
ansible.windows.win_reboot:
when: update_result.reboot_required
- name: Wait for the host to come back online
ansible.builtin.wait_for_connection:
timeout: 600
- name: Update all choco packages
tags: update_choco
block:
- name: Run Chocolatey upgrade (allow failure, don't mark as failed)
win_command: choco upgrade all -y --ignore-checksums --failonunfound --continue-on-failure
register: choco_result
ignore_errors: true
failed_when: false # << This prevents Ansible from treating it as a failed task
- name: Show Chocolatey output
debug:
var: choco_result
- 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 }}"
register: output
- name: debug
debug:
var: output