From ee1208d5c76c8f62333db4e1c0d3f00d6e11743e Mon Sep 17 00:00:00 2001 From: Bogdan Radulescu Date: Thu, 7 Jan 2016 20:54:10 +0200 Subject: [PATCH] Improove the logrotate state with the map --- apache/logrotate.sls | 10 ++++++---- apache/map.jinja | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apache/logrotate.sls b/apache/logrotate.sls index 4f8039d..3696ad7 100644 --- a/apache/logrotate.sls +++ b/apache/logrotate.sls @@ -1,8 +1,10 @@ -/etc/logrotate.d/apache2: +{% from "apache/map.jinja" import apache with context %} + +{{ apache.logrotatedir }}: file: - managed - contents: | - /var/log/apache2/*.log { + {{ apache.logdir }}/*.log { daily missingok rotate 14 @@ -12,8 +14,8 @@ create 640 root adm sharedscripts postrotate - if /etc/init.d/apache2 status > /dev/null ; then \ - /etc/init.d/apache2 reload > /dev/null; \ + if /etc/init.d/{{ apache.service }} status > /dev/null ; then \ + /etc/init.d/{{ apache.service }} reload > /dev/null; \ fi; endscript prerotate diff --git a/apache/map.jinja b/apache/map.jinja index b0c911f..9603e81 100644 --- a/apache/map.jinja +++ b/apache/map.jinja @@ -17,6 +17,7 @@ 'default_site': 'default', 'default_site_ssl': 'default-ssl', 'logdir': '/var/log/apache2', + 'logrotatedir': '/etc/logrotate.d/apache2', 'wwwdir': '/srv', 'use_require': False, }, @@ -35,6 +36,7 @@ 'default_site': 'default', 'default_site_ssl': 'default-ssl', 'logdir': '/var/log/httpd', + 'logrotatedir': '/etc/logrotate.d/httpd', 'wwwdir': '/var/www', 'use_require': False, },