mirror of
				https://github.com/krislamo/puppet-rsnapshot
				synced 2025-10-31 00:38:34 +00:00 
			
		
		
		
	fix cron overrides (critical)
This commit is contained in:
		
							
								
								
									
										2
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO
									
									
									
									
									
								
							| @@ -1 +1,3 @@ | ||||
| validate for puppet 3 => impossible, misses the .each function | ||||
|  | ||||
| Fix Documentation | ||||
|   | ||||
| @@ -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| | ||||
|   | ||||
| @@ -117,23 +117,51 @@ 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] | ||||
|       } | ||||
|       $minute     = rand_from_array($c_min, "${host}.${level}.minute") | ||||
|     } 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") | ||||
|       $monthday   = rand_from_array($c_monthday, "${host}.${level}.monthday") | ||||
|       $month      = rand_from_array($c_month, "${host}.${level}.month") | ||||
|   | ||||
| @@ -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  => '*', | ||||
|     }, | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user