Make logrotate.conf into a template with defined type #15

Open
wants to merge 3 commits into
from

5 participants

@apowers

It is useful to be able to set defaults for all logrotate logs, especially for those that may be vendor installed and not specifically managed by puppet.
This update converts logrotate.conf from a static file to a template using a defined type very similar to the one used for rules.

@blkperl

+1

@gregswift

If i'm reading this right, it would not touch the logrotate.conf if you don't specify to edit it correct? that would be awesome.

Documented my thoughts in #33

@phibos

+1
Are there any reasons why this feature has not been merged?

@baurmatt

I guess since this PR is a total mess. There were 2 commits added which having nothing to do with the actual PR. I've cleaned it up myself (https://github.com/baurmatt/puppet-logrotate/tree/fix_pr15) but want to do some refactoring before creating a new PR. My idea was, to have one template which can be used for /etc/logrotate.conf and /etc/logrotate.d/* since those files are exactly the same beside the additional "<%= rpath %> {" and "}" lines. @rodjek some thoughts about this?

@robinbowes robinbowes commented on the diff Mar 3, 2015
manifests/base.pp
# Examples
#
# include logrotate::base
-class logrotate::base {
+class logrotate::base (
+ $ensure = 'latest'
+) {
+
+ case $ensure {
+ 'latest': { $_ensure = 'latest' }
+ false,'absent': { $_ensure = 'absent' }
+ default: { $_ensure = 'presest' }
@robinbowes
robinbowes added a line comment Mar 3, 2015

Typo - should be "present"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@robinbowes robinbowes commented on the diff Mar 3, 2015
manifests/conf.pp
+ $start = 'undef',
+ $uncompresscmd = 'undef'
+) {
+
+#############################################################################
+# SANITY CHECK VALUES
+
+ if $name !~ /^[a-zA-Z0-9\._\/-]+$/ {
+ fail("Logrotate::Rule[${name}]: namevar must be alphanumeric")
+ }
+
+ case $ensure {
+ 'present','file': {}
+ 'absent': {}
+ default: {
+ fail("Logrotate::Rule[${name}]: invalid ensure value")
@robinbowes
robinbowes added a line comment Mar 3, 2015

All instances of Logrotate::Rule in the fail messages in this class should be Logrotate::Conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment