4
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
---
|
---
|
||||||
- name: Patch Domain Controllers via SYSTEM scheduled task
|
- name: Patch DCs via SYSTEM scheduled task
|
||||||
hosts: domain_controllers
|
hosts: domain_controllers
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Start the SYSTEM patch task
|
- name: Start the SYSTEM patch task
|
||||||
community.windows.win_scheduled_task:
|
ansible.windows.win_powershell:
|
||||||
name: "Patching-windows-task"
|
script: |
|
||||||
state: started
|
Start-ScheduledTask -TaskName 'Patching-windows-task'
|
||||||
|
|
||||||
- name: Wait until the task finishes
|
- name: Wait until the task finishes
|
||||||
community.windows.win_scheduled_task_stat:
|
community.windows.win_scheduled_task_stat:
|
||||||
name: "Patching-windows-task"
|
name: "Patching-windows-task"
|
||||||
register: patch_task
|
register: patch_task
|
||||||
until: patch_task.task.state in ['Ready','Disabled'] # Task finished
|
until: patch_task.task.state in ['Ready','Disabled'] # finished
|
||||||
retries: 180 # check for up to 3 hours
|
retries: 180
|
||||||
delay: 60 # wait 60s between checks
|
delay: 60
|
||||||
|
|
||||||
- name: Reboot DC if needed (belt & suspenders)
|
- name: Reboot if needed
|
||||||
ansible.windows.win_reboot:
|
ansible.windows.win_reboot:
|
||||||
reboot_timeout: 3600
|
reboot_timeout: 3600
|
||||||
when: patch_task.task.state == 'Ready'
|
when: patch_task.task.state == 'Ready'
|
||||||
Reference in New Issue
Block a user