Akosiaris has uploaded a new change for review. https://gerrit.wikimedia.org/r/96247
Change subject: Change the way cron run times are calculated ...................................................................... Change the way cron run times are calculated Make the puppet run interval more configurable by allowing to modify it by changing a single value instead of a value + a cron entry. The ERB calculates the cron entry now using the interval and crontimes values. An assumption is made that the maximum interval is 60 minutes and the minimum 1 minute. Change-Id: Ie44b37f45a2962954927e988947315e8d9459400 --- M modules/base/manifests/init.pp M modules/base/templates/puppet.cron.erb 2 files changed, 13 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/47/96247/1 diff --git a/modules/base/manifests/init.pp b/modules/base/manifests/init.pp index eca45a6..f86c20e 100644 --- a/modules/base/manifests/init.pp +++ b/modules/base/manifests/init.pp @@ -191,7 +191,9 @@ ## run puppet by cron and ## rotate puppet logs generated by cron - $crontime = fqdn_rand(30) + ## This is in mins. Do not set this to 0 or > 60 + $interval = 30 + $crontime = fqdn_rand(60) file { "/etc/cron.d/puppet": diff --git a/modules/base/templates/puppet.cron.erb b/modules/base/templates/puppet.cron.erb index 4450ed0..e8d9424 100644 --- a/modules/base/templates/puppet.cron.erb +++ b/modules/base/templates/puppet.cron.erb @@ -2,6 +2,14 @@ ##### THIS FILE IS MANAGED BY PUPPET ##### as template('base/puppet.cron.erb') ###################################################################### -<% $crontime = scope.lookupvar('base::puppet::crontime') -%> -<%= $crontime %>,<%= $crontime.to_i + 30 %> * * * * root timeout <% if scope.function_versioncmp([lsbdistrelease, "12.04"]) >= 0 %> -k 300<% end %> 1800 puppet agent --onetime --verbose --no-daemonize --no-splay --show_diff >> /var/log/puppet.log 2>&1 +<%- +interval = scope.lookupvar('base::puppet::interval') +crontime = scope.lookupvar('base::puppet::crontime') +numtimes = 60 / interval +tmp = Array.new(numtimes) { |t| t = t * interval + crontime } +tmp = tmp.map { |x| if x < 60 then x else x - 60 end } +tmp = tmp.sort() +times = tmp.join(',') +-%> +<%= times %> * * * * root timeout <% if scope.function_versioncmp([lsbdistrelease, "12.04"]) >= 0 %> -k 300<% end %> 1800 puppet agent --onetime --verbose --no-daemonize --no-splay --show_diff >> /var/log/puppet.log 2>&1 @reboot root timeout <% if scope.function_versioncmp([lsbdistrelease, "12.04"]) >= 0 %> -k 300<% end %> 1800 puppet agent --onetime --verbose --no-daemonize --no-splay --show_diff >> /var/log/puppet.log 2>&1 -- To view, visit https://gerrit.wikimedia.org/r/96247 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie44b37f45a2962954927e988947315e8d9459400 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Akosiaris <akosia...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits