-
Notifications
You must be signed in to change notification settings - Fork 23
Add support for multiple cron agent runs per hour #167
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class puppet::agent::cron ( | ||
$enable = true, | ||
$run_noop = false, | ||
$enable = true, | ||
$run_noop = false, | ||
$frequency = 1 | ||
) { | ||
include puppet::params | ||
|
||
|
@@ -16,9 +17,13 @@ | |
$cmd = "${puppet::params::puppet_cmd} agent --confdir ${puppet::params::puppet_confdir} --onetime --no-daemonize >/dev/null" | ||
} | ||
|
||
$interval = 60 / $frequency | ||
$random_offset = fqdn_rand($interval) | ||
$cron_schedule = $frequency.map |$value| { ($value * $interval) + $random_offset} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhm, does this mean it's puppet 4 only code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @igalic correct, future-parser only. I'm no longer running current parser anywhere so I have no personal need for backwards compatibility, but I wanted to get feedback before going further because I realize that not everybody is ready to make the switch. If requiring future parser isn't feasible for other puppet-puppet users, I think the second-best option would be to simply parameterize puppet::agent to accept a field passed directly to the If future-parser-only code would cause problems for you, I'm totally fine solving this another way -- I just wanted to propose what I see as the most elegant fix first, in case others are fine with future parser. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gosh, i really want to switch. |
||
|
||
cron { 'puppet agent': | ||
ensure => $ensure, | ||
command => $cmd, | ||
minute => fqdn_rand(60), | ||
minute => $cron_schedule, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class { 'puppet::agent': | ||
method => 'cron', | ||
method => 'cron', | ||
frequency => 2, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to $cron_frequency please? (only here, not in puppet::agent::cron)