Ansible/playbook/roles/windows_scheduled_tasks/tasks/main.yaml

53 lines
1.4 KiB
YAML

- name: Reboot Scheduled Tasks
community.windows.win_scheduled_task:
name: Reboot
description: open command prompt
actions:
- path: shutdown.exe
arguments: /r
triggers:
- type: daily
start_boundary: '2024-01-01T23:30:00'
username: SYSTEM
state: present
enabled: yes
- name: Choco Update Scheduled Tasks
community.windows.win_scheduled_task:
name: Choco Update
description: open command prompt
actions:
- path: C:\ProgramData\chocolatey\choco.exe
arguments: upgrade all --yes --confirm
triggers:
- type: daily
start_boundary: '2024-01-01T22:30:00'
username: SYSTEM
state: present
enabled: yes
- name: Install NuGet
ansible.builtin.win_shell:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
- name: Register a PowerShell repository
ansible.builtin.win_shell:
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
- name: Add Windows Update Module
ansible.builtin.win_shell:
Install-Module -Name PSWindowsUpdate
- name: Windows Update Scheduled Tasks
community.windows.win_scheduled_task:
name: Windows Update
description: open command prompt
actions:
- path: powershell.exe
arguments: -command "Get-WindowsUpdate -AcceptAll -Install"
triggers:
- type: daily
start_boundary: '2024-01-01T22:30:00'
username: SYSTEM
state: present
enabled: yes