Skip to content

Commit 7865b7b

Browse files
authored
Merge pull request #5 from jps-help/deb822_source
Update documentation and testing
2 parents f5921b7 + a71f58b commit 7865b7b

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@ apt::source { 'puppetlabs':
225225

226226
<a id="configure-apt-from-hiera"></a>
227227

228+
### Generating a DEB822 .sources file
229+
230+
You can also generate a DEB822 format .sources file. This example covers most of the available options.
231+
232+
Use the `source_format` parameter to choose between 'list' and 'sources' (DEB822) formats.
233+
```puppet
234+
apt::source { 'debian':
235+
source_format => 'sources'
236+
comment => 'Official Debian Repository',
237+
enabled => true,
238+
types => ['deb', 'deb-src'],
239+
location => ['http://fr.debian.org/debian', 'http://de.debian.org/debian']
240+
release => ['stable', 'stable-updates', 'stable-backports'],
241+
repos => ['main', 'contrib', 'non-free'],
242+
architecture => ['amd64', 'i386'],
243+
allow_unsigned => true,
244+
keyring => '/etc/apt/keyrings/debian.gpg'
245+
notify_update => false
246+
}
247+
```
248+
228249
### Configure Apt from Hiera
229250

230251
Instead of specifying your sources directly as resources, you can instead just include the `apt` class, which will pick up the values automatically from hiera.

spec/defines/source_spec.rb

+65
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,69 @@
416416
it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }
417417
end
418418
end
419+
420+
describe 'deb822 sources' do
421+
let :params do
422+
{
423+
source_format: 'sources',
424+
}
425+
end
426+
427+
context 'basic deb822 source' do
428+
let :params do
429+
super().merge(
430+
{
431+
location: ['http://debian.mirror.iweb.ca/debian/'],
432+
repos: ['main', 'contrib', 'non-free']
433+
},
434+
)
435+
end
436+
437+
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) }
438+
end
439+
440+
context 'complex deb822 source' do
441+
let :params do
442+
super().merge(
443+
{
444+
types: ['deb', 'deb-src'],
445+
location: ['http://fr.debian.org/debian', 'http://de.debian.org/debian'],
446+
release: ['stable', 'stable-updates', 'stable-backports'],
447+
repos: ['main', 'contrib', 'non-free'],
448+
architecture: ['amd64', 'i386'],
449+
allow_unsigned: true,
450+
notify_update: false
451+
},
452+
)
453+
end
454+
455+
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(false) }
456+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Enabled: yes}) }
457+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Types: deb deb-src}) }
458+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{URIs: http://fr.debian.org/debian http://de.debian.org/debian}) }
459+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Suites: stable stable-updates stable-backports}) }
460+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Components: main contrib non-free}) }
461+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Architectures: amd64 i386}) }
462+
it { is_expected.to contain_apt__setting("sources-#{title}").with_content(%r{Trusted: yes}) }
463+
end
464+
465+
context '.list backwards compatibility' do
466+
let :params do
467+
super().merge(
468+
{
469+
location: 'http://debian.mirror.iweb.ca/debian/',
470+
release: 'unstable',
471+
repos: 'main contrib non-free',
472+
key: {
473+
id: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
474+
server: 'keyserver.ubuntu.com',
475+
},
476+
pin: '-10'
477+
},
478+
)
479+
end
480+
481+
it { is_expected.to contain_apt__setting("sources-#{title}").with_notify_update(true) }
482+
end
483+
end
419484
end

0 commit comments

Comments
 (0)