[BUG] Cannot add multiple triggers to windows scheduled task
Author: nychefCreated Apr 24, 2025Updated Sep 29, 2026
Labelsbugneeds-triage
Description When adding triggers to a scheduled task, the second trigger of the same type fails. This is because the ID of the trigger needs to be unique within the task but the id in win_task.py is statically set to [type]_ID1
Setup
example sls:
{% for foo in ['fizz', 'bang', 'clang'] %}
{% set task_name = 'task_' + foo %}
task-{{ task_name }}:
task.present:
- name: {{ task_name }}
- user_name: System
- location: ""
- idle_stop_on_end: False
- ac_only: False
- stop_if_on_batteries: False
- start_time: "09:00"
- trigger_type: Weekly
- weeks_interval: 1
- days_of_week: ['Monday','Tuesday','Wednesday','Thursday', 'Friday']
- action_type: Execute
- cmd: dir
{% for time in ["10:00",'11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00'] %}
task-trigger-{{ task_name }}-{{ time|replace(":","") }}:
module.run:
- task.add_trigger:
- name: {{ task_name }}
- trigger_type: Weekly
- days_of_week: ['Monday','Tuesday','Wednesday','Thursday', 'Friday']
- trigger_enabled: True
- start_time: '{{ time }}'
- execution_time_limit: '72 hours'
{% endfor %}
{% endif %}
{% endfor %}Please be as specific as possible and give set-up details.
- [ X ] on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- [ X ] classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior run a state that adds multiple triggers of the same type to the same windows scheduled task
Expected behavior triggers are added
Versions Report
master is 3006.0 and the minion is also 3006.0. win_task.py module and state have been included as custom from 3007
Source: saltstack/salt