|
|
|
|
|
|
|
|
include: |
|
|
include: |
|
|
- logrotate |
|
|
- logrotate |
|
|
|
|
|
|
|
|
|
|
|
{% set ns = namespace(hourly=False) %} |
|
|
|
|
|
{% set jobs = salt['config.get']('logrotate:jobs', {}) %} |
|
|
|
|
|
{% for key, value in logrotate.jobs.items() %} |
|
|
|
|
|
{% set contents = value.get('contents', False) %} |
|
|
|
|
|
{% if 'hourly' in (contents or value.config) %} |
|
|
|
|
|
{% set ns.hourly = True %} |
|
|
|
|
|
{% break %} |
|
|
|
|
|
{% endif %} |
|
|
|
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
logrotate-config: |
|
|
logrotate-config: |
|
|
file.managed: |
|
|
file.managed: |
|
|
- name: {{ logrotate.conf_file }} |
|
|
- name: {{ logrotate.conf_file }} |
|
|
- source: salt://logrotate/templates/logrotate.conf.tmpl |
|
|
- source: salt://logrotate/templates/logrotate.conf.tmpl |
|
|
- template: jinja |
|
|
- template: jinja |
|
|
- 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') }} |
|
|
|
|
|
|
|
|
- user: {{ salt['config.get']('logrotate:config:user', logrotate.user) }} |
|
|
|
|
|
- group: {{ salt['config.get']('logrotate:config:group', logrotate.group) }} |
|
|
|
|
|
- mode: {{ salt['config.get']('logrotate:config:mode', '0644') }} |
|
|
- context: |
|
|
- context: |
|
|
logrotate: {{ logrotate|tojson }} |
|
|
logrotate: {{ logrotate|tojson }} |
|
|
|
|
|
|
|
|
logrotate-directory: |
|
|
logrotate-directory: |
|
|
file.directory: |
|
|
file.directory: |
|
|
- name: {{ logrotate.include_dir }} |
|
|
- name: {{ logrotate.include_dir }} |
|
|
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }} |
|
|
|
|
|
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }} |
|
|
|
|
|
- mode: 755 |
|
|
|
|
|
|
|
|
- user: {{ salt['config.get']('logrotate:config:user', logrotate.user) }} |
|
|
|
|
|
- group: {{ salt['config.get']('logrotate:config:group', logrotate.group) }} |
|
|
|
|
|
- mode: '0755' |
|
|
|
|
|
- makedirs: True |
|
|
|
|
|
|
|
|
|
|
|
{%- if ns.hourly %} |
|
|
|
|
|
logrotate-hourly-config: |
|
|
|
|
|
file.managed: |
|
|
|
|
|
- name: {{ logrotate.hourly_conf_file }} |
|
|
|
|
|
- user: {{ salt['config.get']('logrotate:config:user', logrotate.user) }} |
|
|
|
|
|
- group: {{ salt['config.get']('logrotate:config:group', logrotate.group) }} |
|
|
|
|
|
- mode: {{ salt['config.get']('logrotate:config:mode', '0644') }} |
|
|
|
|
|
- contents: |
|
|
|
|
|
- include {{ logrotate.hourly_include_dir }} |
|
|
|
|
|
|
|
|
|
|
|
logrotate-hourly-directory: |
|
|
|
|
|
file.directory: |
|
|
|
|
|
- name: {{ logrotate.hourly_include_dir }} |
|
|
|
|
|
- user: {{ logrotate.user }} |
|
|
|
|
|
- group: {{ logrotate.group }} |
|
|
|
|
|
- mode: '0755' |
|
|
- makedirs: True |
|
|
- makedirs: True |
|
|
|
|
|
|
|
|
|
|
|
logrotate-hourly-cron: |
|
|
|
|
|
file.managed: |
|
|
|
|
|
- name: "/etc/cron.hourly/logrotate" |
|
|
|
|
|
- source: salt://logrotate/templates/logrotate.hourly.tmpl |
|
|
|
|
|
- template: jinja |
|
|
|
|
|
- user: {{ salt['config.get']('logrotate:config:user', logrotate.user) }} |
|
|
|
|
|
- group: {{ salt['config.get']('logrotate:config:group', logrotate.group) }} |
|
|
|
|
|
- mode: '0775' |
|
|
|
|
|
- context: |
|
|
|
|
|
logrotate: {{ logrotate|tojson }} |
|
|
|
|
|
|
|
|
|
|
|
{%- endif %} |