rotate must be an integer
The parsing of rotate appears to differ from the official documentation. In the examples, rotate is presented as a Ruby Fixnum. In the code, the match criteria appears to only work for numeric characters from a Ruby String.
This is working for me:
logrotate::rule { 'redis_6384':
path => '/var/log/redis_6384.log',
rotate => '4',
mail => '',
rotate_every => 'week'
}
This block returns an error:
logrotate::rule { 'redis_6384':
path => '/var/log/redis_6384.log',
rotate => 4,
mail => '',
rotate_every => 'week'
}
==> data: Error: Logrotate::Rule[redis_6384]: rotate must be an integer on node db01.hostname.dev
Am I misunderstanding something? Is the documentation wrong? Is the parser incorrect?
Thanks!
Just for clarity here - are you using the future parser? Getting the same thing right after changing over here. Puppet 3.7.3
I am seeing this specifically with the entries in manifests/defaults/debian.pp, if I change the Logrotate::rule definition to use rotate => '1' instead of rotate => 1, it works fine.
just a note - https://github.com/rodjek/puppet-logrotate/commit/d569bcee1b43fa1af816c21afb5664d8e5235553 fixes this issue. use master instead of 1.1.1, or @rodjek may be nice enough to arrange a version bump? :)
+1 for this, I had to manually fix this. Please get this updated in forge, it would be appreciated.
Future parser stops being future Q1 2015 (aka soon).
Hey, any progress here? could you bump the version to release the fix?
Just ran into this. What is stopping this from progressing to a patch release?
(Looking at it, wouldn't a better fix than those proposed be to just do case "${rotate}" { on :302?)
The problem is that regex matches explicitly (according to the manual[0]) only match strings - so an integer (as demanded) will never match!
[0] - https://docs.puppetlabs.com/puppet/latest/reference/lang_conditional.html#case-matching
Yes, this was with the future parser.
What's stopping this from being released into the forge? I've just run into the same problem when I started using this module today (1.1.1 from the forge).
Can I somehow avoid this error:
Evaluation Error: Error while evaluating a Function Call, Logrotate::Rule[wtmp]: rotate must be an integer at .../modules/logrotate/manifests/rule.pp:306:7
without using the "master". The wtmp 'Rule' is inside the logrotate module, so I do not know how to influence/overwrite it.
Well, the maintainer really should fix their broken module.
Meanwhile, one hacky workaround:
Put the following in a file, say ~/logrotate.patch:
From 29bb3c2b64fd5c5ba718c1100d7f380b86637d13 Mon Sep 17 00:00:00 2001
From: Peter Bridgman <[email protected]>
Date: Mon, 21 Sep 2015 07:23:06 +0100
Subject: [PATCH] Fixes integer validation in Puppet 4
Case regex validation only succeeds on strings, which is somewhat
troublesome when using them to validate integers. By forcing any
passed integers to be strings, we cause integers to match the regex as
desired.
---
manifests/rule.pp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/manifests/rule.pp b/manifests/rule.pp
index 22b5201..a8b7fe4 100644
--- a/manifests/rule.pp
+++ b/manifests/rule.pp
@@ -296,7 +296,7 @@
}
}
- case $maxage {
+ case "${maxage}" {
'undef': {}
/^\d+$/: {}
default: {
@@ -312,7 +312,7 @@
}
}
- case $rotate {
+ case "${rotate}" {
'undef': {}
/^\d+$/: {}
default: {
@@ -328,7 +328,7 @@
}
}
- case $shredcycles {
+ case "${shredcycles}" {
'undef': {}
/^\d+$/: {}
default: {
@@ -336,7 +336,7 @@
}
}
- case $start {
+ case "${start}" {
'undef': {}
/^\d+$/: {}
default: {
(SPOILER ALERT: this is just #62)
Then:
$ cd /etc/puppetlabs/code/environments/production/modules/logrotate
$ patch -i ~/logrotate.patch -p1
Yes, I know this is horrific. It also makes the problem go away for a bit.
I'm having this too.
I just asked Tim per EMail, if he still (wants to) maintain this repo
Just ran into this as well. Any update on making a release?
I also have this problem with v1.1.1 using the above patch works, but is not suitable for a production system.
bump
go with this fork, approved by puppet folks https://forge.puppet.com/yo61/logrotate