1
0
Fork 0
mirror of synced 2024-12-22 06:01:08 -05:00
formula-logrotate/logrotate/jobs.sls

41 lines
1.3 KiB
Text
Raw Normal View History

2015-01-21 05:00:07 -05:00
# vim: sts=2 ts=2 sw=2 et ai
{% from "logrotate/map.jinja" import logrotate with context %}
{% set jobs = salt['pillar.get']('logrotate:jobs', {}) %}
2015-01-21 05:00:07 -05:00
include:
- logrotate
{% for key, value in jobs.items() %}
{% set contents = value.get('contents', False) %}
logrotate-{{ key }}:
2015-01-21 05:00:07 -05:00
file.managed:
{% if 'hourly' in (contents or value.config) %}
- name: {{ logrotate.hourly_include_dir }}/{{ key.split("/")[-1] }}
- require:
- file: {{ logrotate.hourly_include_dir }}
{% else %}
2015-01-21 05:00:07 -05:00
- name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }}
{% endif %}
2015-01-21 05:00:07 -05:00
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
- require:
- pkg: logrotate-pkg
{% if contents %}
- contents: {{ contents | yaml_encode }}
{% else %}
- source: salt://logrotate/templates/job.tmpl
- template: jinja
2015-01-21 05:00:07 -05:00
- context:
{% if value is mapping %}
path: {{ value.get('path', [key]) | json }}
data: {{ value.get('config', []) | json }}
{% else %}
path: [ {{ key | json }} ]
data: {{ value | json }}
{% endif %}
{% endif %}
{% endfor %}