Add support for RandomSleep to 10periodic
This commit is contained in:
parent
6619ad843f
commit
a6b560c9b4
4 changed files with 22 additions and 0 deletions
|
@ -283,6 +283,7 @@ apt::sources:
|
||||||
* `download`: How often, in days, to run `apt-get upgrade --download-only`.
|
* `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.
|
* `upgrade`: How often, in days, to upgrade packages included in the origins list.
|
||||||
* `autoclean`: How often, in days, to run `apt-get autoclean`.
|
* `autoclean`: How often, in days, to run `apt-get autoclean`.
|
||||||
|
* `randomsleep`: How long, in seconds, to randomly wait before applying upgrades.
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ class apt::unattended_upgrades (
|
||||||
$remove_unused = true,
|
$remove_unused = true,
|
||||||
$auto_reboot = false,
|
$auto_reboot = false,
|
||||||
$dl_limit = 'NONE',
|
$dl_limit = 'NONE',
|
||||||
|
$randomsleep = undef,
|
||||||
$enable = '1',
|
$enable = '1',
|
||||||
$backup_interval = '0',
|
$backup_interval = '0',
|
||||||
$backup_level = '3',
|
$backup_level = '3',
|
||||||
|
@ -48,6 +49,12 @@ class apt::unattended_upgrades (
|
||||||
)
|
)
|
||||||
validate_array($origins)
|
validate_array($origins)
|
||||||
|
|
||||||
|
if $randomsleep {
|
||||||
|
unless is_numeric($randomsleep) {
|
||||||
|
fail('randomsleep must be numeric')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
package { 'unattended-upgrades':
|
package { 'unattended-upgrades':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,14 @@ describe 'apt::unattended_upgrades', :type => :class do
|
||||||
it { expect { should raise_error(Puppet::Error) } }
|
it { expect { should raise_error(Puppet::Error) } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'bad randomsleep' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
'randomsleep' => '4ever'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { expect { should raise_error(Puppet::Error) } }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'defaults' do
|
context 'defaults' do
|
||||||
|
@ -123,6 +131,7 @@ describe 'apt::unattended_upgrades', :type => :class 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::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::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 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
|
end
|
||||||
|
|
||||||
context 'anything but defaults' do
|
context 'anything but defaults' do
|
||||||
|
@ -157,6 +166,7 @@ describe 'apt::unattended_upgrades', :type => :class do
|
||||||
'remove_unused' => false,
|
'remove_unused' => false,
|
||||||
'auto_reboot' => true,
|
'auto_reboot' => true,
|
||||||
'dl_limit' => '70',
|
'dl_limit' => '70',
|
||||||
|
'randomsleep' => '1799',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -183,6 +193,7 @@ describe 'apt::unattended_upgrades', :type => :class do
|
||||||
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::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::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::Verbose "1";}}
|
||||||
|
it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep "1799";}}
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,3 +10,6 @@ APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>";
|
||||||
APT::Periodic::Unattended-Upgrade "<%= @upgrade %>";
|
APT::Periodic::Unattended-Upgrade "<%= @upgrade %>";
|
||||||
APT::Periodic::AutocleanInterval "<%= @autoclean %>";
|
APT::Periodic::AutocleanInterval "<%= @autoclean %>";
|
||||||
APT::Periodic::Verbose "<%= @verbose %>";
|
APT::Periodic::Verbose "<%= @verbose %>";
|
||||||
|
<%- unless @randomsleep.nil? -%>
|
||||||
|
APT::Periodic::RandomSleep "<%= @randomsleep %>";
|
||||||
|
<%- end -%>
|
||||||
|
|
Loading…
Reference in a new issue