1
0
mirror of https://github.com/krislamo/puppet-rsnapshot synced 2024-12-16 01:30:35 +00:00

fix cron overrides (critical)

This commit is contained in:
Norbert Varzariu 2015-12-22 00:20:58 +01:00
parent 729ca63fe5
commit 4f41f41579
4 changed files with 70 additions and 38 deletions

2
TODO
View File

@ -1 +1,3 @@
validate for puppet 3 => impossible, misses the .each function
Fix Documentation

View File

@ -4,6 +4,8 @@ This function checks an input struct for undefined hashes in key => hash and ass
EOS
)do |args|
fail "Must receive one argument." if args.empty?
return args if args.is_a?(String)
return args if args.is_a?(Integer)
args.each do |arg|
h = Hash.new
arg.each_pair do |host, hash|

View File

@ -117,21 +117,49 @@ class rsnapshot::config (
concat { $cronfile:
}
$backup_levels.each |String $level| {
if validate_hash($hash) {
# allow to globally override ranges, create random numbers for backup_levels daily, weekly, monthly
if has_key($host, 'cron'){
$c_min = pick($host['cron'][$level]['minute'], $rsnapshot::params::cron[$level]['minute'], '*')
$c_hour = pick($host['cron'][$level]['hour'], $rsnapshot::params::cron[$level]['hour'], '*')
$c_monthday = pick($host['cron'][$level]['monthday'], $rsnapshot::params::cron[$level]['monthday'], '*')
$c_month = pick($host['cron'][$level]['month'], $rsnapshot::params::cron[$level]['month'], '*')
$c_weekday = pick($host['cron'][$level]['weekday'], $rsnapshot::params::cron[$level]['weekday'], '*')
if has_key($hash,cron){
if has_key($hash[cron], $level) {
$cron = $hash[cron][$level]
if has_key($cron, minute) {
$c_min = $cron[minute]
} else {
$c_min = $rsnapshot::params::cron[$level][minute]
}
if has_key($cron, hour) {
$c_hour = $cron[hour]
} else {
$c_hour = $rsnapshot::params::cron[$level][hour]
}
if has_key($cron, monthday) {
$c_monthday = $cron[monthday]
} else {
$c_monthday = $rsnapshot::params::cron[$level][monthday]
}
if has_key($cron, month) {
$c_month = $cron[month]
} else {
$c_month = $rsnapshot::params::cron[$level][month]
}
if has_key($cron, weekday) {
$c_weekday = $cron[weekday]
} else {
$c_weekday = $rsnapshot::params::cron[$level][weekday]
}
} else {
$c_min = $rsnapshot::params::cron[$level]['minute']
$c_hour = $rsnapshot::params::cron[$level]['hour']
$c_monthday = $rsnapshot::params::cron[$level]['monthday']
$c_month = $rsnapshot::params::cron[$level]['month']
$c_weekday = $rsnapshot::params::cron[$level]['weekday']
$c_min = $rsnapshot::params::cron[$level][minute]
$c_hour = $rsnapshot::params::cron[$level][hour]
$c_monthday = $rsnapshot::params::cron[$level][monthday]
$c_month = $rsnapshot::params::cron[$level][month]
$c_weekday = $rsnapshot::params::cron[$level][weekday]
}
} else {
$c_min = $rsnapshot::params::cron[$level][minute]
$c_hour = $rsnapshot::params::cron[$level][hour]
$c_monthday = $rsnapshot::params::cron[$level][monthday]
$c_month = $rsnapshot::params::cron[$level][month]
$c_weekday = $rsnapshot::params::cron[$level][weekday]
}
$minute = rand_from_array($c_min, "${host}.${level}.minute")
$hour = rand_from_array($c_hour, "${host}.${level}.hour")

View File

@ -62,33 +62,33 @@ class rsnapshot::params {
}
$config_backup_scripts = {}
$cron = {
'hourly' => {
'minute' => '0..59',
'hour' => '*', # you could also do: ['21..23','0..4','5'],
'monthday' => '*',
'month' => '*',
'weekday' => '*',
hourly => {
minute => '0..59',
hour => '*', # you could also do: ['21..23','0..4','5'],
monthday => '*',
month => '*',
weekday => '*',
},
'daily' => {
'minute' => '0..59',
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
'monthday' => '*',
'month' => '*',
'weekday' => '*',
daily => {
minute => '0..59',
hour => '0..23', # you could also do: ['21..23','0..4','5'],
monthday => '*',
month => '*',
weekday => '*',
},
'weekly' => {
'minute' => '0..59',
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
'monthday' => '*',
'month' => '*',
'weekday' => '0..6',
weekly => {
minute => '0..59',
hour => '0..23', # you could also do: ['21..23','0..4','5'],
monthday => '*',
month => '*',
weekday => '0..6',
},
'monthly' => {
'minute' => '0..59',
'hour' => '0..23', # you could also do: ['21..23','0..4','5'],
'monthday' => '0..28',
'month' => '*',
'weekday' => '*',
monthly => {
minute => '0..59',
hour => '0..23', # you could also do: ['21..23','0..4','5'],
monthday => '0..28',
month => '*',
weekday => '*',
},
}
}