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 %}
|
2015-10-12 11:21:04 -04:00
|
|
|
{% set jobs = salt['pillar.get']('logrotate:jobs', {}) %}
|
2015-01-21 05:00:07 -05:00
|
|
|
|
|
|
|
include:
|
|
|
|
- logrotate
|
|
|
|
|
2017-02-14 06:52:25 -05:00
|
|
|
{% for key, value in jobs.items() %}
|
2018-07-12 06:44:01 -04:00
|
|
|
{% set contents = value.get('contents', False) %}
|
2021-11-23 15:28:41 -05:00
|
|
|
|
2017-02-14 06:52:25 -05:00
|
|
|
logrotate-{{ key }}:
|
2015-01-21 05:00:07 -05:00
|
|
|
file.managed:
|
2021-11-23 15:28:41 -05:00
|
|
|
{% 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] }}
|
2021-11-23 15:28:41 -05:00
|
|
|
{% 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:
|
2017-02-14 06:50:32 -05:00
|
|
|
- pkg: logrotate-pkg
|
2018-07-12 06:44:01 -04:00
|
|
|
{% if contents %}
|
|
|
|
- contents: {{ contents | yaml_encode }}
|
|
|
|
{% else %}
|
|
|
|
- source: salt://logrotate/templates/job.tmpl
|
|
|
|
- template: jinja
|
2015-01-21 05:00:07 -05:00
|
|
|
- context:
|
2015-05-05 09:20:54 -04:00
|
|
|
{% if value is mapping %}
|
2019-04-11 09:04:32 -04:00
|
|
|
path: {{ value.get('path', [key]) | json }}
|
|
|
|
data: {{ value.get('config', []) | json }}
|
2015-05-05 09:20:54 -04:00
|
|
|
{% else %}
|
2019-04-11 09:04:32 -04:00
|
|
|
path: [ {{ key | json }} ]
|
|
|
|
data: {{ value | json }}
|
2015-05-05 09:20:54 -04:00
|
|
|
{% endif %}
|
2018-07-12 06:44:01 -04:00
|
|
|
{% endif %}
|
|
|
|
|
2021-11-23 15:28:41 -05:00
|
|
|
{% endfor %}
|