blob: 84a943c47990faf60a8d760063ed388487749e97 [file] [log] [blame]
Filip Pytlounf5383a42015-10-06 16:28:32 +02001{%- from "linux/map.jinja" import system with context %}
2{%- if system.enabled %}
3
chnyda82215412017-11-03 10:01:39 +01004include:
5- linux.system.user
Dmitry Teselkin0f084a02018-08-29 14:46:38 +03006- linux.system.cron
chnyda82215412017-11-03 10:01:39 +01007
Dmitry Teselkin0f084a02018-08-29 14:46:38 +03008 {%- for name, job in system.job.items() %}
9 {%- set job_user = job.get('user', 'root') %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020010
11linux_job_{{ job.command }}:
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030012 {%- if job.get('enabled', True) %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020013 cron.present:
chnyda8e2aece2017-11-02 13:40:11 +010014 - name: >
15 {{ job.command }}
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030016 {%- if job.get('identifier', True) %}
Filip Pytloun91222222017-08-04 10:55:27 +020017 - identifier: {{ job.get('identifier', job.get('name', name)) }}
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030018 {%- endif %}
19 - user: {{ job_user }}
20 {%- if job.minute is defined %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020021 - minute: '{{ job.minute }}'
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030022 {%- endif %}
23 {%- if job.hour is defined %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020024 - hour: '{{ job.hour }}'
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030025 {%- endif %}
26 {%- if job.daymonth is defined %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020027 - daymonth: '{{ job.daymonth }}'
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030028 {%- endif %}
29 {%- if job.month is defined %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020030 - month: '{{ job.month }}'
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030031 {%- endif %}
32 {%- if job.dayweek is defined %}
Filip Pytlounf5383a42015-10-06 16:28:32 +020033 - dayweek: '{{ job.dayweek }}'
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030034 {%- endif %}
Filip Pytlound281d292017-05-30 15:55:37 +020035 - require:
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030036 - sls: linux.system.cron
37 {%- if job_user in system.get('user', {}).keys() %}
38 - user: system_user_{{ job_user }}
39 {%- endif %}
40 {%- else %}
Vladimir Eremin6c3b8b92016-12-08 11:36:45 -080041 cron.absent:
Filip Pytlounf5383a42015-10-06 16:28:32 +020042 - name: {{ job.command }}
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030043 {%- if job.get('identifier', True) %}
Filip Pytloun91222222017-08-04 10:55:27 +020044 - identifier: {{ job.get('identifier', job.get('name', name)) }}
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030045 {%- endif %}
Vasyl Saienkoe4ab2452019-11-13 15:57:30 +020046 - user: {{ job_user }}
Filip Pytloun91222222017-08-04 10:55:27 +020047 {%- endif %}
Dmitry Teselkin0f084a02018-08-29 14:46:38 +030048 {%- endfor %}
Vladimir Eremin6c3b8b92016-12-08 11:36:45 -080049{%- endif %}