diff --git a/apache/logrotate.sls b/apache/logrotate.sls new file mode 100644 index 0000000..3696ad7 --- /dev/null +++ b/apache/logrotate.sls @@ -0,0 +1,26 @@ +{% from "apache/map.jinja" import apache with context %} + +{{ apache.logrotatedir }}: + file: + - managed + - contents: | + {{ apache.logdir }}/*.log { + daily + missingok + rotate 14 + compress + delaycompress + notifempty + create 640 root adm + sharedscripts + postrotate + if /etc/init.d/{{ apache.service }} status > /dev/null ; then \ + /etc/init.d/{{ apache.service }} reload > /dev/null; \ + fi; + endscript + prerotate + if [ -d /etc/logrotate.d/httpd-prerotate ]; then \ + run-parts /etc/logrotate.d/httpd-prerotate; \ + fi; \ + endscript + } 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, },