Merge pull request #32 from daks/jobs_contents
Adding possibility to submit raw content to configure a job
This commit is contained in:
commit
6575a95764
5 changed files with 101 additions and 4 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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
71
test/integration/default/controls/jobs.rb
Normal file
71
test/integration/default/controls/jobs.rb
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
title 'Test logrotate jobs configuration'
|
||||||
|
|
||||||
|
describe file('/etc/logrotate.d/error') do
|
||||||
|
it { should be_file }
|
||||||
|
it { should be_owned_by 'root' }
|
||||||
|
it { should be_grouped_into 'root' }
|
||||||
|
its('mode') { should cmp '0644' }
|
||||||
|
# FIXME
|
||||||
|
#its('content') { should include '/tmp/var/log/mysql/error' }
|
||||||
|
its('content') { should include 'weekly' }
|
||||||
|
its('content') { should include 'missingok' }
|
||||||
|
its('content') { should include 'rotate 52' }
|
||||||
|
its('content') { should include 'compress' }
|
||||||
|
its('content') { should include 'delaycompress' }
|
||||||
|
its('content') { should include 'notifempty' }
|
||||||
|
its('content') { should include 'create 640 root adm' }
|
||||||
|
its('content') { should include 'sharedscripts' }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/logrotate.d/mysql') do
|
||||||
|
it { should be_file }
|
||||||
|
it { should be_owned_by 'root' }
|
||||||
|
it { should be_grouped_into 'root' }
|
||||||
|
its('mode') { should cmp '0644' }
|
||||||
|
its('content') { should include '/tmp/var/log/mysql/*.log' }
|
||||||
|
its('content') { should include 'weekly' }
|
||||||
|
its('content') { should include 'missingok' }
|
||||||
|
its('content') { should include 'rotate 52' }
|
||||||
|
its('content') { should include 'compress' }
|
||||||
|
its('content') { should include 'delaycompress' }
|
||||||
|
its('content') { should include 'notifempty' }
|
||||||
|
its('content') { should include 'create 640 root adm' }
|
||||||
|
its('content') { should include 'sharedscripts' }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/logrotate.d/syslog') do
|
||||||
|
it { should be_file }
|
||||||
|
it { should be_owned_by 'root' }
|
||||||
|
it { should be_grouped_into 'root' }
|
||||||
|
its('mode') { should cmp '0644' }
|
||||||
|
its('content') { should include '/var/log/cron' }
|
||||||
|
its('content') { should include '/var/log/maillog' }
|
||||||
|
its('content') { should include '/var/log/messages' }
|
||||||
|
its('content') { should include '/var/log/secure' }
|
||||||
|
its('content') { should include '/var/log/spooler' }
|
||||||
|
its('content') { should include '/var/log/slapd.log' }
|
||||||
|
its('content') { should include 'sharedscripts' }
|
||||||
|
its('content') { should include 'postrotate' }
|
||||||
|
its('content') { should include 'sharedscripts' }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe file('/etc/logrotate.d/nginx') do
|
||||||
|
it { should be_file }
|
||||||
|
it { should be_owned_by 'root' }
|
||||||
|
it { should be_grouped_into 'root' }
|
||||||
|
its('mode') { should cmp '0644' }
|
||||||
|
its('content') { should include '/var/log/nginx/*.log' }
|
||||||
|
its('content') { should include 'weekly' }
|
||||||
|
its('content') { should include 'missingok' }
|
||||||
|
its('content') { should include 'compress' }
|
||||||
|
its('content') { should include 'delaycompress' }
|
||||||
|
its('content') { should include 'prerotate' }
|
||||||
|
its('content') { should include 'if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\' }
|
||||||
|
its('content') { should include ' run-parts /etc/logrotate.d/httpd-prerotate; \\' }
|
||||||
|
its('content') { should include ' fi \\' }
|
||||||
|
its('content') { should include 'postrotate' }
|
||||||
|
its('content') { should include ' invoke-rc.d nginx rotate >/dev/null 2>&1' }
|
||||||
|
|
||||||
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
name: shorewall
|
name: logrotate
|
||||||
title: Shorewall Profile
|
title: Logrotate Profile
|
||||||
maintainer: Eric Veiras Galisson
|
maintainer: Eric Veiras Galisson
|
||||||
copyright: Eric Veiras Galisson
|
copyright: Eric Veiras Galisson
|
||||||
copyright_email: eric AT sietch-tabr DOT com
|
copyright_email: eric AT sietch-tabr DOT com
|
||||||
|
|
Loading…
Reference in a new issue