Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Get rid of the underscore prefixed variables that don't work with the…
Browse files Browse the repository at this point in the history
… future parser
  • Loading branch information
rodjek committed Mar 19, 2014
1 parent bab8fb9 commit 1d58f3a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
64 changes: 32 additions & 32 deletions manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -178,105 +178,105 @@

case $compress {
'undef': {}
true: { $_compress = 'compress' }
false: { $_compress = 'nocompress' }
true: { $sane_compress = 'compress' }
false: { $sane_compress = 'nocompress' }
default: {
fail("Logrotate::Rule[${name}]: compress must be a boolean")
}
}

case $copy {
'undef': {}
true: { $_copy = 'copy' }
false: { $_copy = 'nocopy' }
true: { $sane_copy = 'copy' }
false: { $sane_copy = 'nocopy' }
default: {
fail("Logrotate::Rule[${name}]: copy must be a boolean")
}
}

case $copytruncate {
'undef': {}
true: { $_copytruncate = 'copytruncate' }
false: { $_copytruncate = 'nocopytruncate' }
true: { $sane_copytruncate = 'copytruncate' }
false: { $sane_copytruncate = 'nocopytruncate' }
default: {
fail("Logrotate::Rule[${name}]: copytruncate must be a boolean")
}
}

case $create {
'undef': {}
true: { $_create = 'create' }
false: { $_create = 'nocreate' }
true: { $sane_create = 'create' }
false: { $sane_create = 'nocreate' }
default: {
fail("Logrotate::Rule[${name}]: create must be a boolean")
}
}

case $delaycompress {
'undef': {}
true: { $_delaycompress = 'delaycompress' }
false: { $_delaycompress = 'nodelaycompress' }
true: { $sane_delaycompress = 'delaycompress' }
false: { $sane_delaycompress = 'nodelaycompress' }
default: {
fail("Logrotate::Rule[${name}]: delaycompress must be a boolean")
}
}

case $dateext {
'undef': {}
true: { $_dateext = 'dateext' }
false: { $_dateext = 'nodateext' }
true: { $sane_dateext = 'dateext' }
false: { $sane_dateext = 'nodateext' }
default: {
fail("Logrotate::Rule[${name}]: dateext must be a boolean")
}
}

case $mail {
'undef': {}
false: { $_mail = 'nomail' }
false: { $sane_mail = 'nomail' }
default: {
$_mail = "mail ${mail}"
$sane_mail = "mail ${mail}"
}
}

case $missingok {
'undef': {}
true: { $_missingok = 'missingok' }
false: { $_missingok = 'nomissingok' }
true: { $sane_missingok = 'missingok' }
false: { $sane_missingok = 'nomissingok' }
default: {
fail("Logrotate::Rule[${name}]: missingok must be a boolean")
}
}

case $olddir {
'undef': {}
false: { $_olddir = 'noolddir' }
false: { $sane_olddir = 'noolddir' }
default: {
$_olddir = "olddir ${olddir}"
$sane_olddir = "olddir ${olddir}"
}
}

case $sharedscripts {
'undef': {}
true: { $_sharedscripts = 'sharedscripts' }
false: { $_sharedscripts = 'nosharedscripts' }
true: { $sane_sharedscripts = 'sharedscripts' }
false: { $sane_sharedscripts = 'nosharedscripts' }
default: {
fail("Logrotate::Rule[${name}]: sharedscripts must be a boolean")
}
}

case $shred {
'undef': {}
true: { $_shred = 'shred' }
false: { $_shred = 'noshred' }
true: { $sane_shred = 'shred' }
false: { $sane_shred = 'noshred' }
default: {
fail("Logrotate::Rule[${name}]: shred must be a boolean")
}
}

case $ifempty {
'undef': {}
true: { $_ifempty = 'ifempty' }
false: { $_ifempty = 'notifempty' }
true: { $sane_ifempty = 'ifempty' }
false: { $sane_ifempty = 'notifempty' }
default: {
fail("Logrotate::Rule[${name}]: ifempty must be a boolean")
}
Expand All @@ -285,11 +285,11 @@
case $rotate_every {
'undef': {}
'hour', 'hourly': {}
'day': { $_rotate_every = 'daily' }
'week': { $_rotate_every = 'weekly' }
'month': { $_rotate_every = 'monthly' }
'year': { $_rotate_every = 'yearly' }
'daily', 'weekly','monthly','yearly': { $_rotate_every = $rotate_every }
'day': { $sane_rotate_every = 'daily' }
'week': { $sane_rotate_every = 'weekly' }
'month': { $sane_rotate_every = 'monthly' }
'year': { $sane_rotate_every = 'yearly' }
'daily', 'weekly','monthly','yearly': { $sane_rotate_every = $rotate_every }
default: {
fail("Logrotate::Rule[${name}]: invalid rotate_every value")
}
Expand Down Expand Up @@ -345,7 +345,7 @@

case $su {
'undef',false: {}
true: { $_su = 'su' }
true: { $sane_su = 'su' }
default: {
fail("Logrotate::Rule[${name}]: su must be a boolean")
}
Expand All @@ -358,7 +358,7 @@
fail("Logrotate::Rule[${name}]: Can't set both mailfirst and maillast")
}

$_mailfirst = 'mailfirst'
$sane_mailfirst = 'mailfirst'
}
default: {
fail("Logrotate::Rule[${name}]: mailfirst must be a boolean")
Expand All @@ -368,7 +368,7 @@
case $maillast {
'undef',false: {}
true: {
$_maillast = 'maillast'
$sane_maillast = 'maillast'
}
default: {
fail("Logrotate::Rule[${name}]: maillast must be a boolean")
Expand Down
22 changes: 11 additions & 11 deletions templates/etc/logrotate.d/rule.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
rpath = @path
end

if scope.to_hash.has_key?('_create')
if @_create == 'create'
opts << [@_create, @create_mode, @create_owner, @create_group].reject { |r|
if scope.to_hash.has_key?('sane_create')
if @sane_create == 'create'
opts << [@sane_create, @create_mode, @create_owner, @create_group].reject { |r|
r == 'undef'
}.join(' ')
else
opts << @_create
opts << @sane_create
end
end

if scope.to_hash.has_key?('_su')
if @_su == 'su'
opts << [@_su, @su_owner, @su_group].reject { |r|
if scope.to_hash.has_key?('sane_su')
if @sane_su == 'su'
opts << [@sane_su, @su_owner, @su_group].reject { |r|
r == 'undef'
}.join(' ')
end
end

[
'_compress', '_copy', '_copytruncate', '_delaycompress', '_dateext',
'_mail', '_missingok', '_olddir', '_sharedscripts', '_ifempty', '_maillast',
'_mailfirst', '_shred', '_rotate_every'
'compress', 'copy', 'copytruncate', 'delaycompress', 'dateext',
'mail', 'missingok', 'olddir', 'sharedscripts', 'ifempty', 'maillast',
'mailfirst', 'shred', 'rotate_every'
].each do |bool|
opts << scope.to_hash[bool] if scope.to_hash.has_key?(bool)
opts << scope.to_hash["sane_#{bool}"] if scope.to_hash.has_key?("sane_#{bool}")
end

[
Expand Down
Binary file removed vendor/cache/puppetlabs_spec_helper-0.4.1.gem
Binary file not shown.

0 comments on commit 1d58f3a

Please sign in to comment.