From f36bd67c5c738ff4c448e46633fe2115241f7731 Mon Sep 17 00:00:00 2001 From: abrown38 Date: Wed, 30 Apr 2025 09:03:21 +0100 Subject: [PATCH] windows update task --- ansible/roles/win_client/tasks/update.yml | 32 ++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/ansible/roles/win_client/tasks/update.yml b/ansible/roles/win_client/tasks/update.yml index 67a5961..bcfd65b 100644 --- a/ansible/roles/win_client/tasks/update.yml +++ b/ansible/roles/win_client/tasks/update.yml @@ -1,10 +1,36 @@ --- - name: Install all updates and reboot as many times as needed tags: update_windows - ansible.windows.win_updates: - category_names: '*' - reboot: true + 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_windows1 + 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 win_command: choco upgrade all -y tags: update_choco