3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
11 context 'mostly defaults' do
14 :lsbdistid => 'Debian',
15 :lsbdistcodename => 'wheezy',
22 'include_deb' => false,
26 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
27 'ensure' => 'present',
28 'path' => '/etc/apt/sources.list.d/my_source.list',
32 }).with_content(/#file generated by puppet\n# my_source\ndeb-src wheezy main\n/)
36 context 'no defaults' do
39 :lsbdistid => 'Debian',
40 :lsbdistcodename => 'wheezy',
47 'location' => 'http://debian.mirror.iweb.ca/debian/',
50 'include_src' => false,
51 'required_packages' => 'vim',
53 'key_server' => 'pgp.mit.edu',
54 'key_content' => 'GPG key content',
55 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
57 'architecture' => 'x86_64',
58 'trusted_source' => true,
62 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
63 'ensure' => 'present',
64 'path' => '/etc/apt/sources.list.d/my_source.list',
68 }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
71 it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
72 'ensure' => 'present',
74 'origin' => 'debian.mirror.iweb.ca',
78 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({
79 'command' => '/usr/bin/apt-get -y install vim',
80 'logoutput' => 'on_failure',
81 'refreshonly' => true,
87 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({
88 'ensure' => 'present',
90 'key_server' => 'pgp.mit.edu',
91 'key_content' => 'GPG key content',
92 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
97 context 'trusted_source true' do
100 :lsbdistid => 'Debian',
101 :lsbdistcodename => 'wheezy',
102 :osfamily => 'Debian'
107 'include_src' => false,
108 'trusted_source' => true,
112 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
113 'ensure' => 'present',
114 'path' => '/etc/apt/sources.list.d/my_source.list',
118 }).with_content(/#file generated by puppet\n# my_source\ndeb \[trusted=yes\] wheezy main\n/)
122 context 'architecture equals x86_64' do
125 :lsbdistid => 'Debian',
126 :lsbdistcodename => 'wheezy',
127 :osfamily => 'Debian'
132 'include_deb' => false,
133 'architecture' => 'x86_64',
137 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
138 'ensure' => 'present',
139 'path' => '/etc/apt/sources.list.d/my_source.list',
143 }).with_content(/#file generated by puppet\n# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
147 context 'ensure => absent' do
150 :lsbdistid => 'Debian',
151 :lsbdistcodename => 'wheezy',
152 :osfamily => 'Debian'
157 'ensure' => 'absent',
161 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
167 describe 'validation' do
168 context 'no release' do
171 :lsbdistid => 'Debian',
172 :osfamily => 'Debian'
179 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)