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({
17 should create_file("/etc/apt/apt.conf.d/10periodic").with({
25 describe "with param defaults" do
27 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id}:\${distro_codename}-security";\n\};$/) }
30 describe "with origins => ['ubuntu:precise-security']" do
32 { :origins => ['ubuntu:precise-security'] }
34 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
38 describe "blacklist" do
39 describe "with param defaults" do
41 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
44 describe "with blacklist => []" do
46 { :blacklist => ['libc6', 'libc6-dev'] }
48 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
52 describe "with update => 2" do
56 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
59 describe "with download => 2" do
63 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
66 describe "with upgrade => 2" do
70 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
73 describe "with autoclean => 2" do
77 it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
80 describe "with auto_fix => false" do
82 { :auto_fix => false }
84 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
87 describe "with minimal_steps => true" do
89 { :minimal_steps => true }
91 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
94 describe "with install_on_shutdown => true" do
96 { :install_on_shutdown => true }
98 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
101 describe "mail_to" do
102 describe "param defaults" do
104 it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
105 it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
108 describe "with mail_to => user@website, mail_only_on_error => true" do
110 { :mail_to => "user@website",
111 :mail_only_on_error => true }
113 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
114 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
118 describe "with remove_unused => false" do
120 { :remove_unused => false }
122 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
125 describe "with auto_reboot => true" do
127 { :auto_reboot => true }
129 it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
132 describe "dl_limit" do
133 describe "param defaults" do
135 it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
138 describe "with dl_limit => 70" do
140 { :dl_limit => "70" }
142 it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
146 describe "with enable => 0" do
150 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
153 describe "with backup_interval => 1" do
155 { :backup_interval => "1" }
157 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
160 describe "with backup_level => 0" do
162 { :backup_level => "0" }
164 it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
167 describe "with max_age => 1" do
171 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
174 describe "with min_age => 1" do
178 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
181 describe "with max_size => 1" do
185 it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
188 describe "with download_delta => 2" do
190 { :download_delta => "2" }
192 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
195 describe "with verbose => 2" do
199 it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }