define apt::conf (
$content,
$ensure = present,
- $priority = '50'
+ $priority = '50',
) {
-
- file { "${apt::conf_d}/${priority}${name}":
- ensure => $ensure,
- content => template('apt/_header.erb', 'apt/conf.erb'),
- owner => root,
- group => root,
- mode => '0644',
+ apt::setting { "conf-${name}":
+ ensure => $ensure,
+ base_name => $name,
+ setting_type => 'conf',
+ priority => $priority,
+ content => template('apt/_header.erb', 'apt/conf.erb'),
}
}
}
}
- file { '/etc/apt/apt.conf.d/15update-stamp':
- ensure => 'file',
- content => template('apt/_header.erb', 'apt/15update-stamp.erb'),
- group => 'root',
- mode => '0644',
- owner => 'root',
+ apt::setting { 'conf-update-stamp':
+ base_name => 'update-stamp',
+ setting_type => 'conf',
+ priority => 15,
+ content => template('apt/_header.erb', 'apt/15update-stamp.erb'),
}
file { 'sources.list':
define apt::pin(
$ensure = present,
$explanation = "${caller_module_name}: ${name}",
- $order = '',
+ $order = undef,
$packages = '*',
$priority = 0,
$release = '', # a=
$originator = '', # o=
$label = '' # l=
) {
- if $order != '' and !is_integer($order) {
+ if $order and !is_integer($order) {
fail('Only integers are allowed in the apt::pin order param')
}
}
}
-
# According to man 5 apt_preferences:
# The files have either no or "pref" as filename extension
# and only contain alphanumeric, hyphen (-), underscore (_) and period
# be silently ignored.
$file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
- $path = $order ? {
- '' => "${::apt::preferences_d}/${file_name}.pref",
- default => "${::apt::preferences_d}/${order}-${file_name}.pref",
- }
- file { "${file_name}.pref":
- ensure => $ensure,
- path => $path,
- owner => root,
- group => root,
- mode => '0644',
- content => template('apt/_header.erb', 'apt/pin.pref.erb'),
+ apt::setting { "pref-${file_name}":
+ ensure => $ensure,
+ base_name => $file_name,
+ setting_type => 'pref',
+ priority => $order,
+ content => template('apt/_header.erb', 'apt/pin.pref.erb'),
}
}
fail('lsbdistcodename fact not available: release parameter required')
}
- apt::setting { $name:
+ apt::setting { "list-${name}":
ensure => $ensure,
+ base_name => $name,
setting_type => 'list',
content => template('apt/_header.erb', 'apt/source.list.erb'),
notify => Exec['apt_update'],
apt::pin { $name:
ensure => $ensure,
priority => $pin,
- before => Apt::Setting[$name],
+ before => Apt::Setting["list-${name}"],
origin => $host,
}
}
key_server => $key_server,
key_content => $key_content,
key_source => $key_source,
- before => Apt::Setting[$name],
+ before => Apt::Setting["list-${name}"],
}
}
} } }
it {
- is_expected.to contain_apt__setting('debian_unstable').with({
+ is_expected.to contain_apt__setting('list-debian_unstable').with({
'ensure' => 'present',
'notify' => 'Exec[apt_update]',
})
it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
it {
- is_expected.to contain_apt__setting('puppetlabs').with({
+ is_expected.to contain_apt__setting('list-puppetlabs').with({
'ensure' => 'present',
'notify' => 'Exec[apt_update]',
})
let(:title) { 'my_pin' }
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',
+ it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
+ it { is_expected.to contain_apt__setting("pref-my_pin").with({
+ 'setting_type' => 'pref',
+ 'base_name' => 'my_pin',
})
}
end
'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',
+ it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
+ it { is_expected.to contain_apt__setting("pref-my_pin").with({
+ 'setting_type' => 'pref',
+ 'base_name' => 'my_pin',
})
}
end
'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',
+ it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
+ it { is_expected.to contain_apt__setting("pref-my_pin").with({
+ 'setting_type' => 'pref',
+ 'base_name' => 'my_pin',
})
}
end
'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',
+ it { is_expected.to contain_apt__setting("pref-my_pin").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_apt__setting("pref-my_pin").with({
+ 'setting_type' => 'pref',
+ 'base_name' => 'my_pin',
+ 'priority' => 99,
})
}
end
'ensure' => 'absent'
}
end
- it { is_expected.to contain_file("my_pin.pref").with({
+ it { is_expected.to contain_apt__setting("pref-my_pin").with({
'ensure' => 'absent',
})
}
context 'bad characters' do
let(:title) { 'such bad && wow!' }
- it { is_expected.to contain_file("such__bad____wow_.pref") }
+ it { is_expected.to contain_apt__setting("pref-such__bad____wow_") }
end
describe 'validation' do
}
end
- it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
'ensure' => 'present',
}).with_content(/# my_source\ndeb-src wheezy main\n/)
}
}
end
- it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
'ensure' => 'present',
}).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
}
- it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[my_source]').with({
+ it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
'ensure' => 'present',
'priority' => '10',
'origin' => 'debian.mirror.iweb.ca',
})
}
- it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[my_source]').with({
+ it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with({
'ensure' => 'present',
'key' => GPG_KEY_ID,
'key_server' => 'pgp.mit.edu',
}
end
- it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
'ensure' => 'present',
}).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
}
}
end
- it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
'ensure' => 'present',
}).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
}
}
end
- it { is_expected.to contain_apt__setting('my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
'ensure' => 'absent'
})
}