Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd_randomizeddelaysec #585

Merged
merged 5 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/agent/service/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
default => $::puppet::systemd_cmd,
}

$randomizeddelaysec = $::puppet::systemd_randomizeddelaysec

file { "/etc/systemd/system/${::puppet::systemd_unit_name}.timer":
content => template('puppet/agent/systemd.puppet-run.timer.erb'),
notify => [
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
# $systemd_cmd:: Specify command to launch when runmode is
# set 'systemd.timer'.
#
# $systemd_randomizeddelaysec:: Adds a random delay between 0 and this value
# (in seconds) to the timer. Only relevant when
# runmode is 'systemd.timer'.
#
# $show_diff:: Show and report changed files with diff output
#
# $module_repository:: Use a different puppet module repository
Expand Down Expand Up @@ -581,6 +585,7 @@
Array[Enum['cron', 'service', 'systemd.timer', 'none']] $unavailable_runmodes = $puppet::params::unavailable_runmodes,
Optional[String] $cron_cmd = $puppet::params::cron_cmd,
Optional[String] $systemd_cmd = $puppet::params::systemd_cmd,
Integer[0] $systemd_randomizeddelaysec = $puppet::params::systemd_randomizeddelaysec,
Boolean $agent_noop = $puppet::params::agent_noop,
Boolean $show_diff = $puppet::params::show_diff,
Optional[Stdlib::HTTPUrl] $module_repository = $puppet::params::module_repository,
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
$aio_package = ($::osfamily == 'Windows' or $::rubysitedir =~ /\/opt\/puppetlabs\/puppet/)
$deb_naio_package = ($::osfamily == 'Debian')

$systemd_randomizeddelaysec = 0

case $::osfamily {
'Windows' : {
# Windows prefixes normal paths with the Data Directory's path and leaves 'puppet' off the end
Expand Down
3 changes: 3 additions & 0 deletions spec/classes/puppet_agent_service_systemd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
should contain_file('/etc/systemd/system/puppet-run.timer').
with_content(/.*OnCalendar\=\*-\*-\* \*\:10,40:00.*/)

should contain_file('/etc/systemd/system/puppet-run.timer').
with_content(/^RandomizedDelaySec\=0$/)

should contain_file('/etc/systemd/system/puppet-run.service').
with_content(/.*ExecStart=#{bindir}\/puppet agent --config #{confdir}\/puppet.conf --onetime --no-daemonize.*/)

Expand Down
1 change: 1 addition & 0 deletions templates/agent/systemd.puppet-run.timer.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description=Systemd Timer for Puppet Agent
[Timer]
OnCalendar=*-*-* <%= Array(@times[0]).join(',') %>:<%= Array(@times[1]).join(',') %>:00
Persistent=true
RandomizedDelaySec=<%= @randomizeddelaysec %>

[Install]
WantedBy=timers.target