diff --git a/modules/logrotate/manifests/file.pp b/modules/logrotate/manifests/file.pp new file mode 100644 index 0000000000..6fcabda37d --- /dev/null +++ b/modules/logrotate/manifests/file.pp @@ -0,0 +1,20 @@ +define logrotate::file($log, + $options, + $prerotate='undef', + $postrotate='undef', + $firstaction='undef', + $lastaction='undef') { + + # $options should be an array containing 1 or more logrotate + # directives (e.g. missingok, compress). + + include logrotate + + file { "/etc/logrotate.d/${name}": + owner => root, + group => root, + mode => 644, + content => template("logrotate/config.erb"), + require => File["/etc/logrotate.d"], + } +} diff --git a/modules/logrotate/manifests/init.pp b/modules/logrotate/manifests/init.pp new file mode 100644 index 0000000000..ec29bc85da --- /dev/null +++ b/modules/logrotate/manifests/init.pp @@ -0,0 +1,16 @@ +# Adapted from http://projects.puppetlabs.com/projects/1/wiki/Logrotate_Patterns + +class logrotate { + + package { "logrotate": + ensure => latest, + } + + file { "/etc/logrotate.d": + ensure => directory, + owner => root, + group => root, + mode => 755, + require => Package["logrotate"], + } +} diff --git a/modules/logrotate/templates/config.erb b/modules/logrotate/templates/config.erb new file mode 100644 index 0000000000..58c8cf0031 --- /dev/null +++ b/modules/logrotate/templates/config.erb @@ -0,0 +1,24 @@ +<%= log %> { +<% options.each do |opt| -%> <%= opt %> +<% end -%> +<% if prerotate != 'undef' -%> + prerotate + <%= prerotate %> + endscript +<% end -%> +<% if postrotate != 'undef' -%> + postrotate + <%= postrotate %> + endscript +<% end -%> +<% if firstaction != 'undef' -%> + firstaction + <%= firstaction %> + endscript +<% end -%> +<% if lastaction != 'undef' -%> + lastaction + <%= lastaction %> + endscript +<% end -%> +}