2 describe 'apt::unattended_upgrades', :type => :class do
3 let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
4 let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
6 it { should contain_package("unattended-upgrades") }
9 should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({
13 "require" => "Package[unattended-upgrades]",
18 should create_file("/etc/apt/apt.conf.d/10periodic").with({
22 "require" => "Package[unattended-upgrades]",
27 describe "with param defaults" do
29 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id}:\${distro_codename}-security";\n\};$/) }
32 describe "with origins => ['ubuntu:precise-security']" do
34 { :origins => ['ubuntu:precise-security'] }
36 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
40 describe "blacklist" do
41 describe "with param defaults" do
43 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
46 describe "with blacklist => []" do
48 { :blacklist => ['libc6', 'libc6-dev'] }
50 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
54 describe "with update => 2" do
58 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
61 describe "with download => 2" do
65 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
68 describe "with upgrade => 2" do
72 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
75 describe "with autoclean => 2" do
79 it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
82 describe "with auto_fix => false" do
84 { :auto_fix => false }
86 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
89 describe "with minimal_steps => true" do
91 { :minimal_steps => true }
93 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
96 describe "with install_on_shutdown => true" do
98 { :install_on_shutdown => true }
100 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
103 describe "mail_to" do
104 describe "param defaults" do
106 it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
107 it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
110 describe "with mail_to => user@website, mail_only_on_error => true" do
112 { :mail_to => "user@website",
113 :mail_only_on_error => true }
115 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
116 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
120 describe "with remove_unused => false" do
122 { :remove_unused => false }
124 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
127 describe "with auto_reboot => true" do
129 { :auto_reboot => true }
131 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
134 describe "dl_limit" do
135 describe "param defaults" do
137 it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
140 describe "with dl_limit => 70" do
142 { :dl_limit => "70" }
144 it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
148 describe "with enable => 0" do
152 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
155 describe "with backup_interval => 1" do
157 { :backup_interval => "1" }
159 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
162 describe "with backup_level => 0" do
164 { :backup_level => "0" }
166 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
169 describe "with max_age => 1" do
173 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
176 describe "with min_age => 1" do
180 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
183 describe "with max_size => 1" do
187 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
190 describe "with download_delta => 2" do
192 { :download_delta => "2" }
194 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
197 describe "with verbose => 2" do
201 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }