[BUG] Cannot add multiple triggers to windows scheduled task
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
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
PASTE HERE
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in win_task.py and trace how trigger IDs are assigned when task.add_trigger handles repeated trigger_type values. Reproduce the issue with the provided state and confirm that adding multiple Weekly triggers to one Windows scheduled task succeeds with distinct IDs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100