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' }
5 let(:facts) { { :lsbdistid => 'Debian' } }
7 it { should contain_package("unattended-upgrades") }
10 should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({
14 "require" => "Package[unattended-upgrades]",
19 should create_file("/etc/apt/apt.conf.d/10periodic").with({
23 "require" => "Package[unattended-upgrades]",
28 describe "with param defaults" do
30 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\$\{distro_id\}:\$\{distro_codename\}-security";\n\};$/) }
33 describe "with origins => ['ubuntu:precise-security']" do
35 { :origins => ['ubuntu:precise-security'] }
37 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
41 describe "blacklist" do
42 describe "with param defaults" do
44 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
47 describe "with blacklist => []" do
49 { :blacklist => ['libc6', 'libc6-dev'] }
51 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
55 describe "with update => 2" do
59 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
62 describe "with download => 2" do
66 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
69 describe "with upgrade => 2" do
73 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
76 describe "with autoclean => 2" do
80 it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
83 describe "with auto_fix => false" do
85 { :auto_fix => false }
87 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
90 describe "with minimal_steps => true" do
92 { :minimal_steps => true }
94 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
97 describe "with install_on_shutdown => true" do
99 { :install_on_shutdown => true }
101 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
104 describe "mail_to" do
105 describe "param defaults" do
107 it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
108 it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
111 describe "with mail_to => user@website, mail_only_on_error => true" do
113 { :mail_to => "user@website",
114 :mail_only_on_error => true }
116 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
117 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
121 describe "with remove_unused => false" do
123 { :remove_unused => false }
125 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
128 describe "with auto_reboot => true" do
130 { :auto_reboot => true }
132 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
135 describe "dl_limit" do
136 describe "param defaults" do
138 it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
141 describe "with dl_limit => 70" do
143 { :dl_limit => "70" }
145 it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
149 describe "with enable => 0" do
153 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
156 describe "with backup_interval => 1" do
158 { :backup_interval => "1" }
160 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
163 describe "with backup_level => 0" do
165 { :backup_level => "0" }
167 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
170 describe "with max_age => 1" do
174 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
177 describe "with min_age => 1" do
181 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
184 describe "with max_size => 1" do
188 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
191 describe "with download_delta => 2" do
193 { :download_delta => "2" }
195 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
198 describe "with verbose => 2" do
202 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }