From 208feadbcdca61dd84fa48331344c3cdbe7ca52f Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Tue, 28 Jul 2015 17:05:16 +0200 Subject: [PATCH] Add logrotate class to Apache Adding this subclass to httpd configuration, to allow modules using this manifest to setup log rotation for apache on demand. Please note that apache is installing a logrotate file by default here, but naming that on same way will overwrite it, and allow our desired log rotation. Depends-On: I7451ecc550b50b85c55784ef598f6b45412117fc Change-Id: I3ef60fd9386795007e5b55264cc6e91fa0b67c68 --- manifests/logrotate.pp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 manifests/logrotate.pp diff --git a/manifests/logrotate.pp b/manifests/logrotate.pp new file mode 100644 index 0000000..c9bad6d --- /dev/null +++ b/manifests/logrotate.pp @@ -0,0 +1,39 @@ +# == Class: httpd::logrotate +# +class httpd::logrotate ( + $options = [ + 'daily', + 'missingok', + 'rotate 30', + 'compress', + 'delaycompress', + 'notifempty', + 'create 640 root adm', + ], + $prerotate = [ + "if [ -d /etc/logrotate.d/${::httpd::params::apache_name}-prerotate ]; then \\", + " run-parts /etc/logrotate.d/${::httpd::params::apache_name}-prerotate; \\", + 'fi; \\', + ], + $postrotate = [ + "if service ${::httpd::params::apache_name} status > /dev/null ; then \\", + " service ${::httpd::params::apache_name} reload > /dev/null; \\", + 'fi; \\', + ], + $firstaction = 'undef', + $lastaction = 'undef', +) inherits httpd::params { + include ::logrotate + + $apache_logdir = "/var/log/${::httpd::params::apache_name}" + $logrotate_name = $::httpd::params::apache_name + + ::logrotate::file { $logrotate_name: + log => "${apache_logdir}/*.log", + options => $options, + prerotate => $prerotate, + postrotate => $postrotate, + firstaction => $firstaction, + lastaction => $lastaction, + } +}