* `download`: How often, in days, to run `apt-get upgrade --download-only`.
* `upgrade`: How often, in days, to upgrade packages included in the origins list.
* `autoclean`: How often, in days, to run `apt-get autoclean`.
+* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades.
### Testing
$remove_unused = true,
$auto_reboot = false,
$dl_limit = 'NONE',
+ $randomsleep = undef,
$enable = '1',
$backup_interval = '0',
$backup_level = '3',
)
validate_array($origins)
+ if $randomsleep {
+ unless is_numeric($randomsleep) {
+ fail('randomsleep must be numeric')
+ }
+ }
+
package { 'unattended-upgrades':
ensure => present,
}
it { expect { should raise_error(Puppet::Error) } }
end
+ context 'bad randomsleep' do
+ let :params do
+ {
+ 'randomsleep' => '4ever'
+ }
+ end
+ it { expect { should raise_error(Puppet::Error) } }
+ end
end
context 'defaults' do
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}}
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}}
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}}
+ it { is_expected.to_not contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep}}
end
context 'anything but defaults' do
'remove_unused' => false,
'auto_reboot' => true,
'dl_limit' => '70',
+ 'randomsleep' => '1799',
}
end
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}}
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}}
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep "1799";}}
end
end
APT::Periodic::Unattended-Upgrade "<%= @upgrade %>";
APT::Periodic::AutocleanInterval "<%= @autoclean %>";
APT::Periodic::Verbose "<%= @verbose %>";
+<%- unless @randomsleep.nil? -%>
+APT::Periodic::RandomSleep "<%= @randomsleep %>";
+<%- end -%>