I wanted to know how to implement nested loop concept to schedule a job in task scheduler which schedules 2 executables, This is my source yaml
---
scheduledTasks:
# 2 ACTIONS PLEASE CHECK
- name: random_name
description: no description
triggers:
type: "daily"
start_boundary: "2022-11-06T12:58:54"
execution_time_limit: PT4H
enabled: true
repetition:
interval: PT15M
stop_at_duration_end: false
run_level: highest
multiple_instances: 2 #ask
disallow_start_if_on_batteries: true
allow_hard_terminate: true
start_when_available: false
run_only_if_network_available: false
allow_demand_start: true
enabled: true
hidden: false
run_only_if_idle: false
wake_to_run: false
execution_time_limit: PT4H
priority: 7
actions:
- path: C:\Program Files\WindowsApps\Microsoft.WindowsNotepad_11.2406.9.0_x64__8wekyb3d8bbwe\Notepad\Notepad.exe
- path: C:\windows\system32\cmd.exe
This is my Ansible playbook
---
- name: Schedule a Python script
hosts: windows_server
vars_files:
- /mnt/d/programs/source7.yaml
tasks:
- name: Schedule a job from Ansible
community.windows.win_scheduled_task:
name: "{{ item.name }}"
description: "{{ item.description }}"
actions:
- path: "{{ item.actions.path }}"
arguments: "{{ item.action.arguments | default(omit) }}"
run_level: "{{ item.run_level }}"
allow_demand_start: "{{ item.allow_demand_start | default(omit) }}"
multiple_instances: "{{ item.multiple_instances }}"
disallow_start_if_on_batteries: "{{ item.disallow_start_if_on_batteries | default(omit) }}"
stop_if_going_on_batteries: "{{ item.stop_if_going_on_batteries | default(omit) }}"
allow_hard_terminate: "{{ item.allow_hard_terminate }}"
start_when_available: "{{ item.start_when_available }}"
run_only_if_network_available: "{{ item.run_only_if_network_available }}"
run_only_if_idle: "{{ item.run_only_if_idle | default(omit) }}"
hidden: "{{ item.hidden }}"
enabled: "{{ item.enabled | default(omit) }}"
execution_time_limit: "{{ item.execution_time_limit }}"
wake_to_run: "{{ item.wake_to_run }}"
priority: "{{ item.priority | default(omit) }}"
triggers:
- type: "{{ item.triggers.type | default(omit) }}"
start_boundary: "{{ item.triggers.start_boundary }}"
user_id: "{{ item.triggers.user_id | default(omit) }}"
enabled: "{{ item.triggers.enabled | default(omit) }}"
execution_time_limit: "{{ item.triggers.execution_time_limit | default(omit) }}"
repetition:
interval: "{{ item.triggers.repetition.interval | default(omit) }}"
stop_at_duration_end: "{{ item.triggers.repetition.stop_at_duration_end | default(omit) }}"
loop: "{{ scheduledTasks }}"
I wanted to cycle through the list of paths in actions in the source file and schedule it in the task scheduler, I've been going through the documents, couldn't find a appropriate solution.
I tried to use with_nested loop, but that doesn't seem appropriate.
multiple_instances? It there any reason for the question "How to implement nested loop concept to schedule a job in task scheduler which schedules 2 executables?" and focus on a maybe solution?