diff options
author | Felix Barbeira <fbarbeira@gmail.com> | 2015-10-26 09:13:45 +0100 |
---|---|---|
committer | Felix Barbeira <fbarbeira@gmail.com> | 2015-10-26 09:13:45 +0100 |
commit | 032022b6a83f5a207b29bf65aeb6399a0c372fef (patch) | |
tree | 11ae9e6d57692d8e7db12ab5fc38c5c23c9be3df | |
parent | e2c493fc0fb5efe0500e135d6ed1b78f7c5b5038 (diff) |
Include variable 'RandomSleep'.
When the apt job starts, it will sleep for a random period between 0 and
APT::Periodic::RandomSleep seconds. The default value is "1800" so that
the script will stall for up to 30 minutes (1800 seconds) so that the
mirror servers are not crushed by everyone running their updates all at
the same time. Only set this to 0 if you use a local mirror and don't
mind the load spikes. Note that while the apt job is sleeping it will
cause the execution of the rest of your cron.daily jobs to be delayed.
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | manifests/init.pp | 1 | ||||
-rw-r--r-- | spec/classes/unattended_upgrades_spec.rb | 3 | ||||
-rw-r--r-- | templates/periodic.erb | 14 |
4 files changed, 19 insertions, 0 deletions
@@ -93,6 +93,7 @@ Using unattended\_upgrades simply consists of including the module and if needed * `minimal_steps` (`true`): Split the upgrade process into sections to allow shutdown during upgrade. * `origins`: The repositories from which to automatically upgrade included packages. * `package_ensure` (`installed`): The ensure state for the 'unattended-upgrades' package. +* `random_sleep` (`300`): Seconds of delay on the cron job execution. * `size` (`0`): Maximum size of the cache in MB. * `update` (`1`): Do "apt-get update" automatically every n-days. * `upgrade` (`1`): Run the "unattended-upgrade" security upgrade script every n-days. diff --git a/manifests/init.pp b/manifests/init.pp index 6a64f0a..7fe64ca 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,6 +11,7 @@ class unattended_upgrades ( $minimal_steps = true, $origins = $::unattended_upgrades::params::origins, $package_ensure = installed, + $random_sleep = undef, $size = 0, $update = 1, $upgrade = 1, diff --git a/spec/classes/unattended_upgrades_spec.rb b/spec/classes/unattended_upgrades_spec.rb index 72291d5..f361bcb 100644 --- a/spec/classes/unattended_upgrades_spec.rb +++ b/spec/classes/unattended_upgrades_spec.rb @@ -279,6 +279,7 @@ describe 'unattended_upgrades' do 'only_on_error' => true, }, :dl_limit => 70, + :random_sleep => 300, } end it { should contain_package('unattended-upgrades') } @@ -350,6 +351,8 @@ describe 'unattended_upgrades' do /APT::Periodic::AutocleanInterval "5";/ ).with_content( /APT::Periodic::Verbose "1";/ + ).with_content( + /APT::Periodic::RandomSleep "300";/ ) } diff --git a/templates/periodic.erb b/templates/periodic.erb index 1ce615a..780821c 100644 --- a/templates/periodic.erb +++ b/templates/periodic.erb @@ -46,3 +46,17 @@ APT::Periodic::Verbose "<%= @verbose %>"; # 1: progress report (actually any string) # 2: + command outputs (remove -qq, remove 2>/dev/null, add -d) # 3: + trace on +<%- unless @random_sleep.nil? -%> +# +APT::Periodic::RandomSleep "<%= @random_sleep %>"; +# - The apt cron job will delay its execution by a random +# time span between zero and 'APT::Periodic::RandomSleep' +# seconds. +# This is done because otherwise everyone would access the +# mirror servers at the same time and put them collectively +# under very high strain. +# You can set this to '0' if you are using a local mirror and +# do not care about the load spikes. +# Note that sleeping in the apt job will be delaying the +# execution of all subsequent cron.daily jobs. +<%- end -%> |