new possibility to configure a job giving the raw content to store as a file
This commit is contained in:
parent
251937f9c3
commit
4ac8535dd7
2 changed files with 28 additions and 2 deletions
|
@ -6,16 +6,20 @@ include:
|
||||||
- logrotate
|
- logrotate
|
||||||
|
|
||||||
{% for key, value in jobs.items() %}
|
{% for key, value in jobs.items() %}
|
||||||
|
{% set contents = value.get('contents', False) %}
|
||||||
logrotate-{{ key }}:
|
logrotate-{{ key }}:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }}
|
- name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }}
|
||||||
- source: salt://logrotate/templates/job.tmpl
|
|
||||||
- template: jinja
|
|
||||||
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
|
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
|
||||||
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
|
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
|
||||||
- mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
|
- mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
|
||||||
- require:
|
- require:
|
||||||
- pkg: logrotate-pkg
|
- pkg: logrotate-pkg
|
||||||
|
{% if contents %}
|
||||||
|
- contents: {{ contents | yaml_encode }}
|
||||||
|
{% else %}
|
||||||
|
- source: salt://logrotate/templates/job.tmpl
|
||||||
|
- template: jinja
|
||||||
- context:
|
- context:
|
||||||
{% if value is mapping %}
|
{% if value is mapping %}
|
||||||
path: {{ value.get('path', []) }}
|
path: {{ value.get('path', []) }}
|
||||||
|
@ -24,4 +28,6 @@ logrotate-{{ key }}:
|
||||||
path: {{ key }}
|
path: {{ key }}
|
||||||
data: {{ value }}
|
data: {{ value }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
|
|
||||||
|
|
|
@ -47,3 +47,23 @@ logrotate:
|
||||||
- postrotate
|
- postrotate
|
||||||
- /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
|
- /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
|
||||||
- endscript
|
- endscript
|
||||||
|
nginx:
|
||||||
|
contents: |
|
||||||
|
/var/log/nginx/*.log{
|
||||||
|
weekly
|
||||||
|
missingok
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
notifempty
|
||||||
|
create 0640 www-data adm
|
||||||
|
sharedscripts
|
||||||
|
prerotate
|
||||||
|
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
|
||||||
|
run-parts /etc/logrotate.d/httpd-prerotate; \
|
||||||
|
fi \
|
||||||
|
endscript
|
||||||
|
postrotate
|
||||||
|
invoke-rc.d nginx rotate >/dev/null 2>&1
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue