From e70f0818d8ebd875b7f25c1ba37dbdb47d9af800 Mon Sep 17 00:00:00 2001 From: Nicole Scherfenberg Date: Tue, 5 May 2015 15:20:54 +0200 Subject: [PATCH] fixes issue #5 splits config file name and log file path, so you configure both. This fixes #5. --- logrotate/init.sls | 4 ++-- logrotate/jobs.sls | 7 ++++++- pillar.example | 30 +++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/logrotate/init.sls b/logrotate/init.sls index e2fb8e3..c271860 100644 --- a/logrotate/init.sls +++ b/logrotate/init.sls @@ -11,8 +11,8 @@ logrotate: logrotate_directory: file.directory: - name: {{ logrotate.include_dir }} - - user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }} - - group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }} + - user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }} + - group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }} - mode: 755 - makedirs: True - require: diff --git a/logrotate/jobs.sls b/logrotate/jobs.sls index 6b154b4..a4d0ee9 100644 --- a/logrotate/jobs.sls +++ b/logrotate/jobs.sls @@ -6,7 +6,7 @@ include: - logrotate {% for key,value in jobs.iteritems() %} -{{key}}: +logrotate_{{key}}: file.managed: - name: {{ logrotate.include_dir }}/{{ key.split("/")[-1] }} - source: salt://logrotate/templates/job.tmpl @@ -19,6 +19,11 @@ include: - watch_in: - service: {{ logrotate.service }} - context: + {% if value is mapping %} + path: {{ value.get('path', key) }} + data: {{ value.get('config', []) }} + {% else %} path: {{ key }} data: {{ value }} + {% endif %} {%- endfor -%} diff --git a/pillar.example b/pillar.example index 0b35ca2..5f0f89c 100644 --- a/pillar.example +++ b/pillar.example @@ -4,12 +4,24 @@ logrotate: pkg: logrotate service: crond jobs: - /tmp/var/log/mysql/error: - - weekly - - missingok - - rotate 52 - - compress - - delaycompress - - notifempty - - create 640 root adm - - sharedscripts + /tmp/var/log/mysql/error: + config: + - weekly + - missingok + - rotate 52 + - compress + - delaycompress + - notifempty + - create 640 root adm + - sharedscripts + mysql: + path: /tmp/var/log/mysql/*.log + config: + - weekly + - missingok + - rotate 52 + - compress + - delaycompress + - notifempty + - create 640 root adm + - sharedscripts