ansible-role-systemd_service/templates/systemd-timer.j2
Georgina 18a05c1a0d Greater flexibility to timer templating
Allows for the combining of multiple directives of the same type as
the spec allows. An options value can now be specified as a list.
Particularly useful for specifying multiple onCalendar directives.

Change-Id: I2f0408a47861560b7813eeba7b3f2ce682823e1e
2020-10-15 12:05:45 +00:00

32 lines
943 B
Django/Jinja

# {{ ansible_managed }}
[Unit]
Description={{ item.service_name }} timer
[Timer]
{% if item.timer.options is defined %}
{% for key, values in item.timer.options.items() %}
{% if values is iterable and values is not string %}
{% for value in values %}
{{ key }}={{ value }}
{% endfor %}
{% else %}
{{ key }}={{ values }}
{% endif %}
{% endfor %}
{% else %}
{% set OnCalendar = [] %}
{% set _ = OnCalendar.extend([item.timer.cron_minute | default('*')]) %}
{% set _ = OnCalendar.extend([item.timer.cron_hour | default('*')]) %}
{% set _ = OnCalendar.extend([item.timer.cron_day | default('*')]) %}
{% set _ = OnCalendar.extend([item.timer.cron_weekday | default('*')]) %}
{% set _ = OnCalendar.extend([item.timer.cron_month | default('*')]) %}
OnBootSec=30min
Unit={{ item.service_name }}.service
Persistent=true
OnCalendar={{ OnCalendar | join(' ') }}
{% endif %}
[Install]
WantedBy=multi-user.target