$originator = '', # o=
$label = '' # l=
) {
-
include apt::params
$preferences_d = $apt::params::preferences_d
$pin_release = join($pin_release_array, '')
# Read the manpage 'apt_preferences(5)', especially the chapter
- # 'Thea Effect of APT Preferences' to understand the following logic
+ # 'The Effect of APT Preferences' to understand the following logic
# and the difference between specific and general form
if is_array($packages) {
$packages_string = join($packages, ' ')
}
if $packages_string != '*' { # specific form
-
if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
- ( $origin != '' and ( $pin_release != '' or $version != '' )) or
( $version != '' and ( $pin_release != '' or $origin != '' )) {
fail('parameters release, origin, and version are mutually exclusive')
}
-
} else { # general form
-
if $version != '' {
fail('parameter version cannot be used in general form')
}
-
- if ( $pin_release != '' and $origin != '' ) or
- ( $origin != '' and $pin_release != '' ) {
- fail('parmeters release and origin are mutually exclusive')
+ if ( $pin_release != '' and $origin != '' ) {
+ fail('parameters release and origin are mutually exclusive')
}
-
}
file { "${sources_list_d}/${sources_list_d_filename}":
ensure => 'absent',
- mode => '0644',
- owner => 'root',
- group => 'root',
notify => Exec['apt_update'],
}
}
ensure => present,
}
- File {
+ file { '/etc/apt/apt.conf.d/50unattended-upgrades':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
+ content => template('apt/50unattended-upgrades.erb'),
require => Package['unattended-upgrades'],
}
- file {
- '/etc/apt/apt.conf.d/50unattended-upgrades':
- content => template('apt/50unattended-upgrades.erb');
- '/etc/apt/apt.conf.d/10periodic':
- content => template('apt/10periodic.erb');
+ file { '/etc/apt/apt.conf.d/10periodic':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => template('apt/10periodic.erb'),
+ require => Package['unattended-upgrades'],
}
}
require 'spec_helper'
describe 'apt', :type => :class do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
- let :default_params do
- {
- :disable_keys => :undef,
- :always_apt_update => false,
- :purge_sources_list => false,
- :purge_sources_list_d => false,
- }
+
+ context 'defaults' do
+ it { should contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/sources.list',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ 'notify' => 'Exec[apt_update]',
+ })}
+
+ it { should contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
+ 'ensure' => 'directory',
+ 'path' => '/etc/apt/sources.list.d',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'purge' => false,
+ 'recurse' => false,
+ 'notify' => 'Exec[apt_update]',
+ })}
+
+ it { should contain_file('preferences.d').only_with({
+ 'ensure' => 'directory',
+ 'path' => '/etc/apt/preferences.d',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'purge' => false,
+ 'recurse' => false,
+ })}
+
+ it { should contain_file('01proxy').that_notifies('Exec[apt_update]').only_with({
+ 'ensure' => 'absent',
+ 'path' => '/etc/apt/apt.conf.d/01proxy',
+ 'notify' => 'Exec[apt_update]',
+ })}
+
+ it { should contain_file('old-proxy-file').that_notifies('Exec[apt_update]').only_with({
+ 'ensure' => 'absent',
+ 'path' => '/etc/apt/apt.conf.d/proxy',
+ 'notify' => 'Exec[apt_update]',
+ })}
+
+ it { should contain_exec('apt_update').with({
+ 'refreshonly' => 'true',
+ })}
end
- [{},
- {
- :disable_keys => true,
- :always_apt_update => true,
- :proxy_host => true,
- :proxy_port => '3128',
- :purge_sources_list => true,
- :purge_sources_list_d => true,
- },
- {
- :purge_preferences => true,
- :purge_preferences_d => true,
- },
- {
- :disable_keys => false
- }
- ].each do |param_set|
- describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
- let :param_hash do
- default_params.merge(param_set)
- end
+ context 'lots of non-defaults' do
+ let :params do
+ {
+ :always_apt_update => true,
+ :disable_keys => true,
+ :proxy_host => 'foo',
+ :proxy_port => '9876',
+ :purge_sources_list => true,
+ :purge_sources_list_d => true,
+ :purge_preferences => true,
+ :purge_preferences_d => true,
+ :update_timeout => '1',
+ :update_tries => '3',
+ :fancy_progress => true,
+ }
+ end
- let :params do
- param_set
- end
+ it { should contain_file('sources.list').with({
+ 'content' => "# Repos managed by puppet.\n"
+ })}
- let :refresh_only_apt_update do
- if param_hash[:always_apt_update]
- false
- else
- true
- end
- end
+ it { should contain_file('sources.list.d').with({
+ 'purge' => 'true',
+ 'recurse' => 'true',
+ })}
+
+ it { should contain_file('apt-preferences').only_with({
+ 'ensure' => 'absent',
+ 'path' => '/etc/apt/preferences',
+ })}
+
+ it { should contain_file('preferences.d').with({
+ 'purge' => 'true',
+ 'recurse' => 'true',
+ })}
- it { should contain_class("apt::params") }
-
- it {
- if param_hash[:purge_sources_list]
- should contain_file("sources.list").with({
- 'path' => "/etc/apt/sources.list",
- 'ensure' => "present",
- 'owner' => "root",
- 'group' => "root",
- 'mode' => "0644",
- "content" => "# Repos managed by puppet.\n"
- })
- else
- should contain_file("sources.list").with({
- 'path' => "/etc/apt/sources.list",
- 'ensure' => "present",
- 'owner' => "root",
- 'group' => "root",
- 'mode' => "0644",
- 'content' => nil
- })
- end
+ it { should contain_file('99progressbar').only_with({
+ 'ensure' => 'present',
+ 'content' => 'Dpkg::Progress-Fancy "1";',
+ 'path' => '/etc/apt/apt.conf.d/99progressbar',
+ })}
+
+ it { should contain_file('99unauth').only_with({
+ 'ensure' => 'present',
+ 'content' => "APT::Get::AllowUnauthenticated 1;\n",
+ 'path' => '/etc/apt/apt.conf.d/99unauth',
+ })}
+
+ it { should contain_file('01proxy').that_notifies('Exec[apt_update]').only_with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/apt.conf.d/01proxy',
+ 'content' => "Acquire::http::Proxy \"http://foo:9876\";\n",
+ 'notify' => 'Exec[apt_update]',
+ 'mode' => '0644',
+ 'owner' => 'root',
+ 'group' => 'root'
+ })}
+
+ it { should contain_exec('apt_update').with({
+ 'refreshonly' => 'false',
+ 'timeout' => '1',
+ 'tries' => '3',
+ })}
+
+ end
+
+ context 'more non-default' do
+ let :params do
+ {
+ :fancy_progress => false,
+ :disable_keys => false,
}
- it {
- if param_hash[:purge_sources_list_d]
- should create_file("sources.list.d").with({
- 'path' => "/etc/apt/sources.list.d",
- 'ensure' => "directory",
- 'owner' => "root",
- 'group' => "root",
- 'purge' => true,
- 'recurse' => true,
- 'notify' => 'Exec[apt_update]'
- })
- else
- should create_file("sources.list.d").with({
- 'path' => "/etc/apt/sources.list.d",
- 'ensure' => "directory",
- 'owner' => "root",
- 'group' => "root",
- 'purge' => false,
- 'recurse' => false,
- 'notify' => 'Exec[apt_update]'
- })
- end
+ end
+
+ it { should contain_file('99progressbar').only_with({
+ 'ensure' => 'absent',
+ 'path' => '/etc/apt/apt.conf.d/99progressbar',
+ })}
+
+ it { should contain_file('99unauth').only_with({
+ 'ensure' => 'absent',
+ 'path' => '/etc/apt/apt.conf.d/99unauth',
+ })}
+
+ end
+
+ context 'with sources defined on valid osfamily' do
+ let :facts do
+ { :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'Debian',
}
- it {
- if param_hash[:purge_preferences]
- should create_file('apt-preferences').with({
- :ensure => 'absent',
- :path => '/etc/apt/preferences',
- })
- else
- should_not contain_file('apt-preferences')
- end
+ end
+ let(:params) { { :sources => {
+ 'debian_unstable' => {
+ 'location' => 'http://debian.mirror.iweb.ca/debian/',
+ 'release' => 'unstable',
+ 'repos' => 'main contrib non-free',
+ 'required_packages' => 'debian-keyring debian-archive-keyring',
+ 'key' => '55BE302B',
+ 'key_server' => 'subkeys.pgp.net',
+ 'pin' => '-10',
+ 'include_src' => true
+ },
+ 'puppetlabs' => {
+ 'location' => 'http://apt.puppetlabs.com',
+ 'repos' => 'main',
+ 'key' => '4BD6EC30',
+ 'key_server' => 'pgp.mit.edu',
}
+ } } }
- it {
- if param_hash[:purge_preferences_d]
- should create_file("preferences.d").with({
- 'path' => "/etc/apt/preferences.d",
- 'ensure' => "directory",
- 'owner' => "root",
- 'group' => "root",
- 'purge' => true,
- 'recurse' => true,
- })
- else
- should create_file("preferences.d").with({
- 'path' => "/etc/apt/preferences.d",
- 'ensure' => "directory",
- 'owner' => "root",
- 'group' => "root",
- 'purge' => false,
- 'recurse' => false,
- })
- end
- }
+ it {
+ should contain_file('debian_unstable.list').with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/sources.list.d/debian_unstable.list',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ 'notify' => 'Exec[apt_update]',
+ })
+ }
- it {
- should contain_exec("apt_update").with({
- 'command' => "/usr/bin/apt-get update",
- 'refreshonly' => refresh_only_apt_update
- })
- }
+ it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
+ it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
- it {
- if param_hash[:disable_keys] == true
- should create_file("99unauth").with({
- 'content' => "APT::Get::AllowUnauthenticated 1;\n",
- 'ensure' => "present",
- 'path' => "/etc/apt/apt.conf.d/99unauth"
- })
- elsif param_hash[:disable_keys] == false
- should create_file("99unauth").with({
- 'ensure' => "absent",
- 'path' => "/etc/apt/apt.conf.d/99unauth"
- })
- elsif param_hash[:disable_keys] != :undef
- should_not create_file("99unauth").with({
- 'path' => "/etc/apt/apt.conf.d/99unauth"
- })
- end
- }
- describe 'when setting a proxy' do
- it {
- if param_hash[:proxy_host]
- should contain_file('01proxy').with(
- 'path' => '/etc/apt/apt.conf.d/01proxy',
- 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n",
- 'notify' => "Exec[apt_update]"
- )
- else
- should contain_file('01proxy').with(
- 'path' => '/etc/apt/apt.conf.d/01proxy',
- 'notify' => 'Exec[apt_update]',
- 'ensure' => 'absent'
- )
- end
+ it {
+ should contain_file('puppetlabs.list').with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/sources.list.d/puppetlabs.list',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ 'notify' => 'Exec[apt_update]',
+ })
+ }
+
+ it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
+ it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
+ end
+
+ describe 'failing tests' do
+ context 'bad purge_sources_list' do
+ let :params do
+ {
+ 'purge_sources_list' => 'foo'
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error)
+ end
+ end
+
+ context 'bad purge_sources_list_d' do
+ let :params do
+ {
+ 'purge_sources_list_d' => 'foo'
}
end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error)
+ end
+ end
+
+ context 'bad purge_preferences' do
+ let :params do
+ {
+ 'purge_preferences' => 'foo'
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error)
+ end
+ end
+
+ context 'bad purge_preferences_d' do
+ let :params do
+ {
+ 'purge_preferences_d' => 'foo'
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error)
+ end
+ end
+
+ context 'with unsupported osfamily' do
+ let :facts do
+ { :osfamily => 'Darwin', }
+ end
+
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
+ end
end
end
end
+++ /dev/null
-require 'spec_helper'
-describe 'apt' do
- context 'with sources defined on valid osfamily' do
- let :facts do
- { :osfamily => 'Debian',
- :lsbdistcodename => 'precise',
- :lsbdistid => 'Debian',
- }
- end
- let(:params) { { :sources => {
- 'debian_unstable' => {
- 'location' => 'http://debian.mirror.iweb.ca/debian/',
- 'release' => 'unstable',
- 'repos' => 'main contrib non-free',
- 'required_packages' => 'debian-keyring debian-archive-keyring',
- 'key' => '55BE302B',
- 'key_server' => 'subkeys.pgp.net',
- 'pin' => '-10',
- 'include_src' => true
- },
- 'puppetlabs' => {
- 'location' => 'http://apt.puppetlabs.com',
- 'repos' => 'main',
- 'key' => '4BD6EC30',
- 'key_server' => 'pgp.mit.edu',
- }
- } } }
-
- it {
- should contain_file('debian_unstable.list').with({
- 'ensure' => 'present',
- 'path' => '/etc/apt/sources.list.d/debian_unstable.list',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- 'notify' => 'Exec[apt_update]',
- })
- }
-
- it { should contain_file('debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
- it { should contain_file('debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
-
- it {
- should contain_file('puppetlabs.list').with({
- 'ensure' => 'present',
- 'path' => '/etc/apt/sources.list.d/puppetlabs.list',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- 'notify' => 'Exec[apt_update]',
- })
- }
-
- it { should contain_file('puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
- it { should contain_file('puppetlabs.list').with_content(/^deb-src http:\/\/apt.puppetlabs.com precise main$/) }
- end
-
- context 'with unsupported osfamily' do
- let :facts do
- { :osfamily => 'Darwin', }
- end
-
- it do
- expect {
- should compile
- }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/)
- end
- end
-end
})
}
- describe "origins" do
- describe 'on Debian' do
- default_facts = { :lsbdistid => 'Debian' }
- context 'defaults' do
- let :facts do default_facts end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Origins-Pattern/
- ).with_content(
- /"origin=Debian,archive=stable,label=Debian-Security";/
- )
- }
- end
- context 'defaults with custom origin' do
- let :facts do default_facts end
- let :params do { :origins => ['bananana']} end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Origins-Pattern/
- ).with_content(
- /"bananana";/
- )
- }
- end
- context 'defaults with invalid origin' do
- let :facts do default_facts end
- let :params do { :origins => 'bananana'} end
- it {
- expect {subject}.to raise_error(/is not an Array/)
- }
- end
- context 'squeeze' do
- let :facts do default_facts.merge({:lsbdistcodename => 'squeeze'}) end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Allowed-Origins/
- ).with_content(
- /"\${distro_id} \${distro_codename}-lts";/
- ).with_content(
- /"\${distro_id} \${distro_codename}-security";/
- ).with_content(
- /"\${distro_id} oldstable";/
- )
- }
- end
- context 'wheezy' do
- let :facts do default_facts.merge({:lsbdistcodename => 'wheezy'}) end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Origins-Pattern/
- ).with_content(
- /"origin=Debian,archive=stable,label=Debian-Security";/
- )
+ describe 'failing' do
+ let :facts do
+ {
+ 'lsbdistid' => 'debian',
+ 'lsbdistcodename' => 'squeeze',
+ }
+ end
+ context 'bad auto_fix' do
+ let :params do
+ {
+ 'auto_fix' => 'foo',
}
end
+ it { expect { should raise_error(Puppet::Error) } }
end
- describe 'on Ubuntu' do
- default_facts = { :lsbdistid => 'Ubuntu' }
- context 'default' do
- let :facts do default_facts end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Allowed-Origins/
- ).with_content(
- /"\${distro_id}\:\${distro_codename}-security";/
- )
- }
- end
- context 'lucid' do
- let :facts do default_facts.merge({:lsbdistcodename => 'lucid'}) end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Allowed-Origins/
- ).with_content(
- /"\${distro_id} \${distro_codename}-security";/
- )
- }
- end
- context 'precise' do
- let :facts do default_facts.merge({:lsbdistcodename => 'precise'}) end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Allowed-Origins/
- ).with_content(
- /"\${distro_id}\:\${distro_codename}-security";/
- )
- }
- end
- context 'trusty' do
- let :facts do default_facts.merge({:lsbdistcodename => 'trusty'}) end
- it {
- should contain_file(file_unattended).with_content(
- /^Unattended-Upgrade::Allowed-Origins/
- ).with_content(
- /"\${distro_id}\:\${distro_codename}-security";/
- )
+ context 'bad minimal_steps' do
+ let :params do
+ {
+ 'minimal_steps' => 'foo',
}
end
- end
- end
-
- describe "blacklist" do
- describe "with param defaults" do
- let(:params) {{ }}
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
+ it { expect { should raise_error(Puppet::Error) } }
end
- describe "with blacklist => []" do
+ context 'bad install_on_shutdown' do
let :params do
- { :blacklist => ['libc6', 'libc6-dev'] }
+ {
+ 'install_on_shutdown' => 'foo',
+ }
end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
- end
- end
-
- describe "with update => 2" do
- let :params do
- { :update => "2" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) }
- end
-
- describe "with download => 2" do
- let :params do
- { :download => "2" }
+ it { expect { should raise_error(Puppet::Error) } }
end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) }
- end
- describe "with upgrade => 2" do
- let :params do
- { :upgrade => "2" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) }
- end
-
- describe "with autoclean => 2" do
- let :params do
- { :autoclean => "2" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) }
- end
-
- describe "with auto_fix => false" do
- let :params do
- { :auto_fix => false }
- end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) }
- end
-
- describe "with minimal_steps => true" do
- let :params do
- { :minimal_steps => true }
- end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) }
- end
-
- describe "with install_on_shutdown => true" do
- let :params do
- { :install_on_shutdown => true }
- end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
- end
-
- describe "mail_to" do
- describe "param defaults" do
- let(:params) {{ }}
- it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
- it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
- end
-
- describe "with mail_to => user@website, mail_only_on_error => true" do
+ context 'bad mail_only_on_error' do
let :params do
- { :mail_to => "user@website",
- :mail_only_on_error => true }
+ {
+ 'mail_only_on_error' => 'foo',
+ }
end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
- end
- end
-
- describe "with remove_unused => false" do
- let :params do
- { :remove_unused => false }
- end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) }
- end
-
- describe "with auto_reboot => true" do
- let :params do
- { :auto_reboot => true }
- end
- it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
- end
-
- describe "dl_limit" do
- describe "param defaults" do
- let(:params) {{ }}
- it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
+ it { expect { should raise_error(Puppet::Error) } }
end
- describe "with dl_limit => 70" do
+ context 'bad remove_unused' do
let :params do
- { :dl_limit => "70" }
+ {
+ 'remove_unused' => 'foo',
+ }
end
- it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
- end
- end
-
- describe "with enable => 0" do
- let :params do
- { :enable => "0" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) }
- end
-
- describe "with backup_interval => 1" do
- let :params do
- { :backup_interval => "1" }
+ it { expect { should raise_error(Puppet::Error) } }
end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) }
- end
- describe "with backup_level => 0" do
- let :params do
- { :backup_level => "0" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) }
- end
-
- describe "with max_age => 1" do
- let :params do
- { :max_age => "1" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) }
- end
-
- describe "with min_age => 1" do
- let :params do
- { :min_age => "1" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) }
- end
-
- describe "with max_size => 1" do
- let :params do
- { :max_size => "1" }
+ context 'bad auto_reboot' do
+ let :params do
+ {
+ 'auto_reboot' => 'foo',
+ }
+ end
+ it { expect { should raise_error(Puppet::Error) } }
end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) }
- end
- describe "with download_delta => 2" do
- let :params do
- { :download_delta => "2" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) }
- end
+ context 'bad origins' do
+ let :params do
+ {
+ 'origins' => 'foo'
+ }
+ end
+ it { expect { should raise_error(Puppet::Error) } }
+ end
+
+ end
+
+ context 'defaults' do
+ let :facts do
+ {
+ 'lsbdistid' => 'debian',
+ 'lsbdistcodename' => 'squeeze',
+ }
+ end
+
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id} oldstable";\n\t"\${distro_id} \${distro_codename}-security";\n\t"\${distro_id} \${distro_codename}-lts";\n\};} }
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "true";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "false";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "false";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "true";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "false";}}
+
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "1";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "3";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "1";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "1";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "0";}}
+ 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";}}
+ end
+
+ context 'anything but defaults' do
+ let :facts do
+ {
+ 'lsbdistid' => 'debian',
+ 'lsbdistcodename' => 'wheezy',
+ }
+ end
+
+ let :params do
+ {
+ 'enable' => '0',
+ 'backup_interval' => '3',
+ 'backup_level' => '1',
+ 'max_age' => '7',
+ 'min_age' => '1',
+ 'max_size' => '100',
+ 'update' => '0',
+ 'download' => '0',
+ 'download_delta' => '1',
+ 'upgrade' => '0',
+ 'autoclean' => '0',
+ 'verbose' => '1',
+ 'origins' => ['bananas'],
+ 'blacklist' => ['foo', 'bar'],
+ 'auto_fix' => false,
+ 'minimal_steps' => true,
+ 'install_on_shutdown' => true,
+ 'mail_to' => 'root@localhost',
+ 'mail_only_on_error' => true,
+ 'remove_unused' => false,
+ 'auto_reboot' => true,
+ 'dl_limit' => '70',
+ }
+ end
+
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"bananas";\n\};} }
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Package-Blacklist \{\n\t"foo";\n\t"bar";\n\};} }
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::AutoFixInterruptedDpkg "false";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MinimalSteps "true";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::InstallOnShutdown "true";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Mail "root@localhost";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::MailOnlyOnError "true";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Remove-Unused-Dependencies "false";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Automatic-Reboot "true";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Acquire::http::Dl-Limit "70";}}
+
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Enable "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpArchiveInterval "3";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::BackUpLevel "1";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxAge "7";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MinAge "1";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::MaxSize "100";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Update-Package-Lists "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages "0";}}
+ it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Download-Upgradeable-Packages-Debdelta "1";}}
+ 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";}}
- describe "with verbose => 2" do
- let :params do
- { :verbose => "2" }
- end
- it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) }
end
-
end
let(:facts) { { :lsbdistid => 'Debian' } }
let(:title) { 'my_package' }
- describe "should require apt-get update" do
- it { should contain_exec("apt_update").with({
- 'command' => "/usr/bin/apt-get update",
- 'refreshonly' => true
+ describe "defaults" do
+ it { should contain_exec("apt-builddep-my_package").that_notifies('Exec[apt_update]').with({
+ 'command' => "/usr/bin/apt-get -y --force-yes build-dep my_package",
+ 'logoutput' => 'on_failure'
})
}
it { should contain_anchor("apt::builddep::my_package").with({
"/etc/apt/apt.conf.d/00norecommends"
end
- it { should contain_apt__conf('norecommends').with({
- 'priority' => '00',
- 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n"
- })
- }
-
it { should contain_file(filename).with({
'ensure' => 'present',
'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n",
end
describe "when using default parameters" do
- let :params do
- default_params
- end
it { should contain_exec("/usr/bin/apt-get -y install #{title}").with(
- :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
- :timeout => '300'
+ :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
+ :logoutput => 'on_failure',
+ :timeout => '300'
) }
end
require 'spec_helper'
describe 'apt::hold' do
let :facts do {
- :osfamily => 'Debian',
- :lsbdistid => 'Debian',
- :lsbrelease => 'wheezy',
+ :osfamily => 'Debian',
+ :lsbdistid => 'Debian',
+ :lsbrelease => 'wheezy',
} end
let :title do
let :params do default_params end
it 'creates an apt preferences file' do
- should contain_apt__hold(title).with({
- :ensure => 'present',
- :package => title,
- :version => params[:version],
- :priority => 1001,
- })
-
should contain_apt__pin("hold_#{title}").with({
:ensure => 'present',
:packages => title,
let :params do default_params.merge({:ensure => 'absent',}) end
it 'creates an apt preferences file' do
- should contain_apt__hold(title).with({
- :ensure => params[:ensure],
- })
should contain_apt__pin("hold_#{title}").with({
:ensure => params[:ensure],
let :params do default_params.merge({:priority => 990,}) end
it 'creates an apt preferences file' do
- should contain_apt__hold(title).with({
+ should contain_apt__pin("hold_#{title}").with({
:ensure => 'present',
- :package => title,
+ :packages => title,
:version => params[:version],
:priority => params[:priority],
})
+ end
+ end
- should contain_apt__pin("hold_#{title}").with({
+ describe 'package => foo' do
+ let :params do default_params.merge({:package => 'foo'}) end
+
+ it 'creates an apt preferences file' do
+ should contain_apt__pin("hold_foo").with({
:ensure => 'present',
- :packages => title,
+ :packages => 'foo',
:version => params[:version],
- :priority => params[:priority],
+ :priority => 1001,
})
end
end
+
describe 'validation' do
context 'version => {}' do
let :params do { :version => {}, } end
describe 'normal operation' do
describe 'default options' do
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- })
- end
it 'contains the apt_key' do
should contain_apt_key(title).with({
:id => title,
:key => GPG_KEY_ID,
} end
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => GPG_KEY_ID,
- :ensure => 'present',
- })
- end
it 'contains the apt_key' do
should contain_apt_key(title).with({
:id => GPG_KEY_ID,
:ensure => 'absent',
} end
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'absent',
- })
- end
it 'contains the apt_key' do
should contain_apt_key(title).with({
:id => title,
end
end
- describe 'key_content =>' do
+ describe 'set a bunch of things!' do
let :params do {
:key_content => 'GPG key content',
+ :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
+ :key_server => 'pgp.mit.edu',
+ :key_options => 'debug',
} end
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_content => params[:key_content],
- })
- end
it 'contains the apt_key' do
should contain_apt_key(title).with({
:id => title,
:ensure => 'present',
- :source => nil,
- :server => nil,
+ :source => 'http://apt.puppetlabs.com/pubkey.gpg',
+ :server => 'pgp.mit.edu',
:content => params[:key_content],
- :keyserver_options => nil,
+ :keyserver_options => 'debug',
})
end
it 'contains the apt_key present anchor' do
end
end
- describe 'key_source =>' do
- let :params do {
- :key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
+ context "domain with dash" do
+ let(:params) do{
+ :key_server => 'p-gp.m-it.edu',
} end
-
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_source => params[:key_source],
+ it 'contains the apt_key' do
+ should contain_apt_key(title).with({
+ :id => title,
+ :server => 'p-gp.m-it.edu',
})
end
+ end
+
+ context "url" do
+ let :params do
+ {
+ :key_server => 'hkp://pgp.mit.edu',
+ }
+ end
it 'contains the apt_key' do
should contain_apt_key(title).with({
- :id => title,
- :ensure => 'present',
- :source => params[:key_source],
- :server => nil,
- :content => nil,
- :keyserver_options => nil,
+ :id => title,
+ :server => 'hkp://pgp.mit.edu',
})
end
- it 'contains the apt_key present anchor' do
- should contain_anchor("apt_key #{title} present")
- end
end
-
- describe 'key_server =>' do
- context 'domain name' do
- let :params do {
- :key_server => 'pgp.mit.edu',
- } end
-
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_server => 'pgp.mit.edu',
- })
- end
- it 'contains the apt_key' do
- should contain_apt_key(title).with({
- :id => title,
- :ensure => 'present',
- :source => nil,
- :server => params[:key_server],
- :content => nil,
- :keyserver_options => nil,
- })
- end
- it 'contains the apt_key present anchor' do
- should contain_anchor("apt_key #{title} present")
- end
- end
-
- context "domain with dash" do
- let(:params) do{
- :key_server => 'p-gp.m-it.edu',
- } end
- it "should contain apt::key" do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_server => 'p-gp.m-it.edu',
- })
- end
+ context "url with port number" do
+ let :params do
+ {
+ :key_server => 'hkp://pgp.mit.edu:80',
+ }
end
-
- context "domain begin with dash" do
- let(:params) do{
- :key_server => '-pgp.mit.edu',
- } end
- it 'fails' do
- expect { subject } .to raise_error(/does not match/)
- end
+ it 'contains the apt_key' do
+ should contain_apt_key(title).with({
+ :id => title,
+ :server => 'hkp://pgp.mit.edu:80',
+ })
end
+ end
+ end
- context "domain begin with dot" do
- let(:params) do{
- :key_server => '.pgp.mit.edu',
- } end
- it 'fails' do
- expect { subject } .to raise_error(/does not match/)
- end
+ describe 'validation' do
+ context "domain begin with dash" do
+ let(:params) do{
+ :key_server => '-pgp.mit.edu',
+ } end
+ it 'fails' do
+ expect { subject } .to raise_error(/does not match/)
end
+ end
- context "domain end with dot" do
- let(:params) do{
- :key_server => "pgp.mit.edu.",
- } end
- it 'fails' do
- expect { subject } .to raise_error(/does not match/)
- end
+ context "domain begin with dot" do
+ let(:params) do{
+ :key_server => '.pgp.mit.edu',
+ } end
+ it 'fails' do
+ expect { subject } .to raise_error(/does not match/)
end
+ end
- context "url" do
- let (:params) do{
- :key_server => 'hkp://pgp.mit.edu',
- } end
- it "should contain apt::key" do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_server => 'hkp://pgp.mit.edu',
- })
- end
+ context "domain end with dot" do
+ let(:params) do{
+ :key_server => "pgp.mit.edu.",
+ } end
+ it 'fails' do
+ expect { subject } .to raise_error(/does not match/)
end
- context "url with port number" do
- let (:params) do{
- :key_server => 'hkp://pgp.mit.edu:80',
- } end
- it "should contain apt::key" do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_server => 'hkp://pgp.mit.edu:80',
- })
- end
+ end
+ context "exceed character url" do
+ let :params do
+ {
+ :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
+ }
end
-
- context "incorrect port number url" do
- let (:params) do{
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
+ end
+ end
+ context "incorrect port number url" do
+ let :params do
+ {
:key_server => 'hkp://pgp.mit.edu:8008080'
- } end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
- end
+ }
+ end
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
end
- context "incorrect protocol for url" do
- let (:params) do{
+ end
+ context "incorrect protocol for url" do
+ let :params do
+ {
:key_server => 'abc://pgp.mit.edu:80'
- } end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
- end
+ }
end
- context "missing port number url" do
- let (:params) do{
- :key_server => 'hkp://pgp.mit.edu:'
- } end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
- end
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
end
- context "url ending with a dot" do
- let (:params) do{
- :key_server => 'hkp://pgp.mit.edu.'
- } end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
- end
+ end
+ context "missing port number url" do
+ let :params do
+ {
+ :key_server => 'hkp://pgp.mit.edu:'
+ }
end
- context "url begin with a dash" do
- let(:params) do{
- :key_server => "hkp://-pgp.mit.edu",
- } end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
- end
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
end
- context "url with dash" do
- let(:params) do{
- :key_server => 'hkp://p-gp.m-it.edu',
- } end
- it "should contain apt::key" do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_server => 'hkp://p-gp.m-it.edu',
- })
- end
+ end
+ context "url ending with a dot" do
+ let :params do
+ {
+ :key_server => 'hkp://pgp.mit.edu.'
+ }
end
- context "exceed characher url" do
- let (:params) do{
- :key_server => 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu'
- } end
- it 'fails' do
- expect { subject }.to raise_error(/does not match/)
- end
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
end
- end
-
- describe 'key_options =>' do
- let :params do {
- :key_options => 'debug',
+ end
+ context "url begin with a dash" do
+ let(:params) do{
+ :key_server => "hkp://-pgp.mit.edu",
} end
-
- it 'contains the apt::key' do
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- :key_options => 'debug',
- })
- end
- it 'contains the apt_key' do
- should contain_apt_key(title).with({
- :id => title,
- :ensure => 'present',
- :source => nil,
- :server => nil,
- :content => nil,
- :keyserver_options => params[:key_options],
- })
- end
- it 'contains the apt_key present anchor' do
- should contain_anchor("apt_key #{title} present")
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
end
end
- end
-
- describe 'validation' do
context 'invalid key' do
let :title do
'Out of rum. Why? Why are we out of rum?'
expect { subject }.to raise_error(/is not a string/)
end
end
- end
- describe 'duplication' do
- context 'two apt::key resources for same key, different titles' do
- let :pre_condition do
- "apt::key { 'duplicate': key => #{title}, }"
+ context 'invalid ensure' do
+ let :params do
+ {
+ :ensure => 'foo',
+ }
end
-
- it 'contains two apt::key resources' do
- should contain_apt__key('duplicate').with({
- :key => title,
- :ensure => 'present',
- })
- should contain_apt__key(title).with({
- :key => title,
- :ensure => 'present',
- })
- end
-
- it 'contains only a single apt_key' do
- should contain_apt_key('duplicate').with({
- :id => title,
- :ensure => 'present',
- :source => nil,
- :server => nil,
- :content => nil,
- :keyserver_options => nil,
- })
- should_not contain_apt_key(title)
+ it 'fails' do
+ expect { subject }.to raise_error(/does not match/)
end
end
- context 'two apt::key resources, different ensure' do
- let :pre_condition do
- "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+ describe 'duplication' do
+ context 'two apt::key resources for same key, different titles' do
+ let :pre_condition do
+ "apt::key { 'duplicate': key => #{title}, }"
+ end
+
+ it 'contains two apt::key resources' do
+ should contain_apt__key('duplicate').with({
+ :key => title,
+ :ensure => 'present',
+ })
+ should contain_apt__key(title).with({
+ :key => title,
+ :ensure => 'present',
+ })
+ end
+
+ it 'contains only a single apt_key' do
+ should contain_apt_key('duplicate').with({
+ :id => title,
+ :ensure => 'present',
+ :source => nil,
+ :server => nil,
+ :content => nil,
+ :keyserver_options => nil,
+ })
+ should_not contain_apt_key(title)
+ end
end
- it 'informs the user of the impossibility' do
- expect { subject }.to raise_error(/already ensured as absent/)
+
+ context 'two apt::key resources, different ensure' do
+ let :pre_condition do
+ "apt::key { 'duplicate': key => #{title}, ensure => 'absent', }"
+ end
+ it 'informs the user of the impossibility' do
+ expect { subject }.to raise_error(/already ensured as absent/)
+ end
end
end
end
let(:facts) { { :lsbdistid => 'Debian' } }
let(:title) { 'my_pin' }
- let :default_params do
- {
- :ensure => 'present',
- :order => '',
- :packages => '*',
- :priority => '0',
- :release => nil
+ context 'defaults' do
+ it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
+ it { is_expected.to contain_file("my_pin.pref").with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/preferences.d/my_pin.pref',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ })
}
end
- [
- { :params => {},
- :content => "Explanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n"
- },
- {
- :params => {
- :packages => 'apache',
- :priority => '1'
- },
- :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
- },
- {
- :params => {
- :order => 50,
- :packages => 'apache',
- :priority => '1'
- },
- :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
- },
- {
- :params => {
- :ensure => 'absent',
- :packages => 'apache',
- :priority => '1'
- },
- :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n"
- },
- {
- :params => {
- :packages => 'apache',
- :priority => '1',
- :release => 'my_newpin'
- },
- :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n"
- },
- {
- :params => {
- :packages => 'apache',
- :priority => '1',
- :version => '2.2.16*'
- },
- :content => "Explanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n"
- },
- {
- :params => {
- :priority => '1',
- :origin => 'ftp.de.debian.org'
- },
- :content => "Explanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n"
- },
- {
- :params => {
- :packages => 'apache',
- :priority => '1',
- :release => 'stable',
- :codename => 'wheezy',
- :release_version => '3.0',
- :component => 'main',
- :originator => 'Debian',
- :label => 'Debian'
- },
- :content => "Explanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n"
- },
- {
- :params => {
- :packages => ['apache', 'ntop'],
- },
- :content => "Explanation: : my_pin\nPackage: apache ntop\nPin: release a=my_pin\nPin-Priority: 0\n"
- },
- ].each do |param_set|
- describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
- let :param_hash do
- default_params.merge(param_set[:params])
- end
+ context 'set version' do
+ let :params do
+ {
+ 'packages' => 'vim',
+ 'version' => '1',
+ }
+ end
+ it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
+ it { is_expected.to contain_file("my_pin.pref").with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/preferences.d/my_pin.pref',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ })
+ }
+ end
- let :params do
- param_set[:params]
- end
+ context 'set origin' do
+ let :params do
+ {
+ 'packages' => 'vim',
+ 'origin' => 'test',
+ }
+ end
+ it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
+ it { is_expected.to contain_file("my_pin.pref").with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/preferences.d/my_pin.pref',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ })
+ }
+ end
- it { should contain_class("apt::params") }
+ context 'not defaults' do
+ let :params do
+ {
+ 'explanation' => 'foo',
+ 'order' => 99,
+ 'release' => '1',
+ 'codename' => 'bar',
+ 'release_version' => '2',
+ 'component' => 'baz',
+ 'originator' => 'foobar',
+ 'label' => 'foobaz',
+ 'priority' => 10,
+ }
+ end
+ it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
+ it { is_expected.to contain_file("my_pin.pref").with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/preferences.d/99-my_pin.pref',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ })
+ }
+ end
- it { should contain_file("#{title}.pref").with({
- 'ensure' => param_hash[:ensure],
- 'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- 'content' => param_set[:content],
- })
+ context 'ensure absent' do
+ let :params do
+ {
+ 'ensure' => 'absent'
}
end
+ it { is_expected.to contain_file("my_pin.pref").with({
+ 'ensure' => 'absent',
+ })
+ }
+ end
+
+ context 'bad characters' do
+ let(:title) { 'such bad && wow!' }
+ it { is_expected.to contain_file("such__bad____wow_.pref") }
end
- describe 'resource title with invalid chars' do
- context 'spaces' do
- let(:title) { 'oh my god this is not valid' }
- it { should contain_file('oh_my_god_this_is_not_valid.pref') }
+ describe 'validation' do
+ context 'invalid order' do
+ let :params do
+ {
+ 'order' => 'foo',
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /Only integers are allowed/)
+ end
+ end
+
+ context 'packages == * and version' do
+ let :params do
+ {
+ 'version' => '1',
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
+ end
end
- context '#$&*$' do
- let(:title) { 'so && many $* invalid @! things' }
- it { should contain_file('so____many____invalid____things.pref') }
+ context 'packages == * and release and origin' do
+ let :params do
+ {
+ 'origin' => 'test',
+ 'release' => 'foo',
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
+ end
+ end
+
+ context 'specific form with release and origin' do
+ let :params do
+ {
+ 'release' => 'foo',
+ 'origin' => 'test',
+ 'packages' => 'vim',
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
+ end
+ end
+
+ context 'specific form with version and origin' do
+ let :params do
+ {
+ 'version' => '1',
+ 'origin' => 'test',
+ 'packages' => 'vim',
+ }
+ end
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
+ end
end
end
end
require 'spec_helper'
describe 'apt::ppa', :type => :define do
- [
- {
- :lsbdistrelease => '11.04',
- :lsbdistcodename => 'natty',
- :operatingsystem => 'Ubuntu',
- :lsbdistid => 'Ubuntu',
- :package => 'python-software-properties'
- },
- {
- :lsbdistrelease => '12.10',
- :lsbdistcodename => 'quantal',
- :operatingsystem => 'Ubuntu',
- :lsbdistid => 'Ubuntu',
- :package => 'software-properties-common'
- },
- ].each do |platform|
- context "on #{platform[:lsbdistcodename]}" do
- let :facts do
- {
- :lsbdistrelease => platform[:lsbdistrelease],
- :lsbdistcodename => platform[:lsbdistcodename],
- :operatingsystem => platform[:operatingsystem],
- :lsbdistid => platform[:lsbdistid],
- :osfamily => 'Debian',
- }
- end
- let :release do
- "#{platform[:lsbdistcodename]}"
- end
- let :package do
- "#{platform[:package]}"
- end
- let :options do
- "-y"
- end
- ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
- describe "with title #{t}" do
- let :pre_condition do
- 'class { "apt": }'
- end
- let :title do
- t
- end
- let :filename do
- t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
- end
-
- it { should contain_package("#{package}") }
- it { should contain_exec("apt_update").with(
- 'command' => '/usr/bin/apt-get update',
- 'refreshonly' => true
- )
- }
+ describe 'defaults' do
+ let :pre_condition do
+ 'class { "apt": }'
+ end
+ let :facts do
+ {
+ :lsbdistrelease => '11.04',
+ :lsbdistcodename => 'natty',
+ :operatingsystem => 'Ubuntu',
+ :osfamily => 'Debian',
+ :lsbdistid => 'Ubuntu',
+ }
+ end
- it { should contain_exec("add-apt-repository-#{t}").with(
- 'command' => "/usr/bin/add-apt-repository #{options} #{t}",
- 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
- 'require' => ["File[sources.list.d]", "Package[#{package}]"],
- 'notify' => "Exec[apt_update]"
- )
- }
+ let(:title) { 'ppa:needs/such.substitution/wow' }
+ it { is_expected.to contain_package('python-software-properties') }
+ it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
+ 'environment' => [],
+ 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
+ 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
+ 'user' => 'root',
+ 'logoutput' => 'on_failure',
+ })
+ }
- it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
- 'ensure' => 'file',
- 'require' => "Exec[add-apt-repository-#{t}]"
- )
- }
- end
- end
- describe 'without a proxy defined' do
- let :title do
- 'rspec_ppa'
- end
- let :pre_condition do
- 'class { "apt":
- proxy_host => false
- }'
- end
- let :filename do
- "#{title}-#{release}.list"
- end
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
+ 'ensure' => 'file',
+ })
+ }
+ end
- it { should contain_exec("add-apt-repository-#{title}").with(
- 'environment' => [],
- 'command' => "/usr/bin/add-apt-repository #{options} #{title}",
- 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
- 'require' => ["File[sources.list.d]", "Package[#{package}]"],
- 'notify' => "Exec[apt_update]"
- )
- }
- end
+ describe 'apt included, no proxy' do
+ let :pre_condition do
+ 'class { "apt": }'
+ end
+ let :facts do
+ {
+ :lsbdistrelease => '14.04',
+ :lsbdistcodename => 'trusty',
+ :operatingsystem => 'Ubuntu',
+ :lsbdistid => 'Ubuntu',
+ :osfamily => 'Debian',
+ }
+ end
+ let :params do
+ {
+ 'options' => '',
+ }
+ end
+ let(:title) { 'ppa:foo' }
+ it { is_expected.to contain_package('software-properties-common') }
+ it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+ 'environment' => [],
+ 'command' => '/usr/bin/add-apt-repository ppa:foo',
+ 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+ 'user' => 'root',
+ 'logoutput' => 'on_failure',
+ })
+ }
- describe 'behind a proxy' do
- let :title do
- 'rspec_ppa'
- end
- let :pre_condition do
- 'class { "apt":
- proxy_host => "user:pass@proxy",
- }'
- end
- let :filename do
- "#{title}-#{release}.list"
- end
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
+ 'ensure' => 'file',
+ })
+ }
+ end
- it { should contain_exec("add-apt-repository-#{title}").with(
- 'environment' => [
- "http_proxy=http://user:pass@proxy:8080",
- "https_proxy=http://user:pass@proxy:8080",
- ],
- 'command' => "/usr/bin/add-apt-repository #{options} #{title}",
- 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
- 'require' => ["File[sources.list.d]", "Package[#{package}]"],
- 'notify' => "Exec[apt_update]"
- )
- }
- end
+ describe 'apt included, proxy' do
+ let :pre_condition do
+ 'class { "apt": proxy_host => "example.com" }'
end
+ let :facts do
+ {
+ :lsbdistrelease => '14.04',
+ :lsbdistcodename => 'trusty',
+ :operatingsystem => 'Ubuntu',
+ :lsbdistid => 'Ubuntu',
+ :osfamily => 'Debian',
+ }
+ end
+ let :params do
+ {
+ 'release' => 'lucid',
+ }
+ end
+ let(:title) { 'ppa:foo' }
+ it { is_expected.to contain_package('software-properties-common') }
+ it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+ 'environment' => ['http_proxy=http://example.com:8080', 'https_proxy=http://example.com:8080'],
+ 'command' => '/usr/bin/add-apt-repository -y ppa:foo',
+ 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-lucid.list',
+ 'user' => 'root',
+ 'logoutput' => 'on_failure',
+ })
+ }
+
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-lucid.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
+ 'ensure' => 'file',
+ })
+ }
end
- [ { :lsbdistcodename => 'natty',
- :package => 'python-software-properties' },
- { :lsbdistcodename => 'quantal',
- :package => 'software-properties-common'},
- ].each do |platform|
- context "on #{platform[:lsbdistcodename]}" do
- describe "it should not error if package['#{platform[:package]}'] is already defined" do
- let :pre_condition do
- 'class {"apt": }' +
- 'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]'
- end
- let :facts do
- {:lsbdistcodename => '#{platform[:lsbdistcodename]}',
- :operatingsystem => 'Ubuntu',
- :lsbdistid => 'Ubuntu',
- :osfamily => 'Debian'}
- end
- let(:title) { "ppa" }
- let(:release) { "#{platform[:lsbdistcodename]}" }
- it { should contain_package('#{platform[:package]}') }
- end
+ describe 'ensure absent' do
+ let :facts do
+ {
+ :lsbdistrelease => '14.04',
+ :lsbdistcodename => 'trusty',
+ :operatingsystem => 'Ubuntu',
+ :lsbdistid => 'Ubuntu',
+ :osfamily => 'Debian',
+ }
+ end
+ let(:title) { 'ppa:foo' }
+ let :params do
+ {
+ 'ensure' => 'absent'
+ }
end
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
+ 'ensure' => 'absent',
+ })
+ }
end
- describe "without Class[apt] should raise a Puppet::Error" do
- let(:release) { "natty" }
- let(:title) { "ppa" }
- it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) }
- end
+ context 'validation' do
+ describe 'no release' do
+ let :facts do
+ {
+ :lsbdistrelease => '14.04',
+ :operatingsystem => 'Ubuntu',
+ :lsbdistid => 'Ubuntu',
+ :osfamily => 'Debian',
+ }
+ end
+ let(:title) { 'ppa:foo' }
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
+ end
+ end
- describe "without release should raise a Puppet::Error" do
- let(:title) { "ppa:" }
- it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) }
+ describe 'not ubuntu' do
+ let :facts do
+ {
+ :lsbdistrelease => '14.04',
+ :lsbdistcodename => 'trusty',
+ :operatingsystem => 'Debian',
+ :lsbdistid => 'Ubuntu',
+ :osfamily => 'Debian',
+ }
+ end
+ let(:title) { 'ppa:foo' }
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./)
+ end
+ end
end
end
require 'spec_helper'
describe 'apt::source', :type => :define do
- let(:facts) { { :lsbdistid => 'Debian' } }
GPG_KEY_ID = '4BD6EC30'
let :title do
'my_source'
end
- let :default_params do
- {
- :ensure => 'present',
- :location => '',
- :release => 'karmic',
- :repos => 'main',
- :include_src => true,
- :include_deb => true,
- :required_packages => false,
- :key => false,
- :key_server => false,
- :key_content => false,
- :key_source => false,
- :pin => false
- }
- end
+ context 'mostly defaults' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ }
+ end
- [{},
- {
- :location => 'http://example.com',
- :release => 'precise',
- :repos => 'security',
- :include_src => false,
- :required_packages => 'apache',
- :key => GPG_KEY_ID,
- :key_server => 'keyserver.debian.com',
- :pin => '600',
- :key_content => 'ABCD1234'
- },
- {
- :key => GPG_KEY_ID,
- :key_server => 'keyserver.debian.com',
- },
- {
- :ensure => 'absent',
- :location => 'http://example.com',
- :release => 'precise',
- :repos => 'security',
- },
- {
- :release => '',
- },
- {
- :release => 'custom',
- },
- {
- :architecture => 'amd64',
+ let :params do
+ {
+ 'include_deb' => false,
+ }
+ end
+
+ it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/sources.list.d/my_source.list',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ }).with_content(/#file generated by puppet\n# my_source\ndeb-src wheezy main\n/)
}
- ].each do |param_set|
- describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
- let :param_hash do
- default_params.merge(param_set)
- end
+ end
- let :facts do
- {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'}
- end
+ context 'no defaults' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ }
+ end
+ let :params do
+ {
+ 'comment' => 'foo',
+ 'location' => 'http://debian.mirror.iweb.ca/debian/',
+ 'release' => 'sid',
+ 'repos' => 'testing',
+ 'include_src' => false,
+ 'required_packages' => 'vim',
+ 'key' => GPG_KEY_ID,
+ 'key_server' => 'pgp.mit.edu',
+ 'key_content' => 'GPG key content',
+ 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
+ 'pin' => '10',
+ 'architecture' => 'x86_64',
+ }
+ end
- let :params do
- param_set
- end
+ it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+ 'ensure' => 'present',
+ 'path' => '/etc/apt/sources.list.d/my_source.list',
+ 'owner' => 'root',
+ 'group' => 'root',
+ 'mode' => '0644',
+ }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
+ }
- let :filename do
- "/etc/apt/sources.list.d/#{title}.list"
- end
+ it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
+ 'ensure' => 'present',
+ 'priority' => '10',
+ 'origin' => 'debian.mirror.iweb.ca',
+ })
+ }
- let :content do
- content = "#file generated by puppet\n"
- if param_hash[:comment]
- content << "# #{comment}"
- else
- content << "# #{title}"
- end
- if param_hash[:architecture]
- arch = "[arch=#{param_hash[:architecture]}] "
- end
- if param_hash[:include_deb]
- content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
- end
- if param_hash[:include_src]
- content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
- end
- content
- end
+ it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Exec[apt_update]').that_subscribes_to('File[my_source.list]').with({
+ 'command' => '/usr/bin/apt-get -y install vim',
+ 'logoutput' => 'on_failure',
+ 'refreshonly' => true,
+ 'tries' => '3',
+ 'try_sleep' => '1',
+ })
+ }
- it { should contain_apt__params }
+ it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({
+ 'ensure' => 'present',
+ 'key' => GPG_KEY_ID,
+ 'key_server' => 'pgp.mit.edu',
+ 'key_content' => 'GPG key content',
+ 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
+ })
+ }
+ end
- it { should contain_file("#{title}.list").with({
- 'ensure' => param_hash[:ensure],
- 'path' => filename,
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- 'content' => content,
- })
+ context 'ensure => absent' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'wheezy',
}
-
- it {
- if param_hash[:pin]
- should contain_apt__pin(title).with({
- "priority" => param_hash[:pin],
- "before" => "File[#{title}.list]"
- })
- else
- should_not contain_apt__pin(title).with({
- "priority" => param_hash[:pin],
- "before" => "File[#{title}.list]"
- })
- end
+ end
+ let :params do
+ {
+ 'ensure' => 'absent',
}
+ end
- it {
- should contain_exec("apt_update").with({
- "command" => "/usr/bin/apt-get update",
- "refreshonly" => true
- })
- }
+ it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
+ 'ensure' => 'absent'
+ })
+ }
+ end
- it {
- if param_hash[:required_packages]
- should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
- "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
- "subscribe" => "File[#{title}.list]",
- "refreshonly" => true,
- "before" => 'Exec[apt_update]',
- })
- else
- should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
- "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
- "subscribe" => "File[#{title}.list]",
- "refreshonly" => true
- })
- end
- }
+ describe 'validation' do
+ context 'no release' do
+ let :facts do
+ {
+ :lsbdistid => 'Debian',
+ }
+ end
- it {
- key_server = param_hash[:key_server] || nil
- key_content = param_hash[:key_content] || nil
- key_source = param_hash[:key_source] || nil
- if param_hash[:key]
- should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
- "key" => param_hash[:key],
- "ensure" => :present,
- "key_server" => key_server,
- "key_content" => key_content,
- "key_source" => key_source,
- "before" => "File[#{title}.list]"
- })
- else
- should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
- "key" => param_hash[:key],
- "ensure" => :present,
- "key_server" => param_hash[:key_server],
- "key_content" => param_hash[:key_content],
- "key_source" => param_hash[:key_source],
- "before" => "File[#{title}.list]"
- })
- end
- }
+ it do
+ expect {
+ should compile
+ }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
+ end
end
end
- describe "without release should raise a Puppet::Error" do
- let(:default_params) { Hash.new }
- let(:facts) { Hash.new }
- it { expect { should raise_error(Puppet::Error) } }
- let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } }
- it { should contain_apt__source(title) }
- end
end