define apt::setting (
- $priority = 50,
- $ensure = file,
- $source = undef,
- $content = undef,
- $file_perms = {},
+ $priority = 50,
+ $ensure = file,
+ $source = undef,
+ $content = undef,
+ $file_perms = {},
+ $notify_update = true,
) {
$_file = merge($::apt::file_defaults, $file_perms)
}
validate_re($ensure, ['file', 'present', 'absent'])
+ validate_bool($notify_update)
$title_array = split($title, '-')
$setting_type = $title_array[0]
$_path = $::apt::config_files[$setting_type]['path']
$_ext = $::apt::config_files[$setting_type]['ext']
+ if $notify_update {
+ $_notify = Exec['apt_update']
+ } else {
+ $_notify = undef
+ }
+
file { "${_path}/${_priority}${base_name}${_ext}":
ensure => $ensure,
owner => $_file['owner'],
mode => $_file['mode'],
content => $content,
source => $source,
+ notify => $_notify,
+ }
+
+ if $notify_update {
+ anchor { "apt::setting::${name}":
+ require => Class['apt::update']
+ }
}
}
context 'with title=conf-teddybear ' do
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') }
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }
end
context 'with title=pref-teddybear' do
let(:title) { 'pref-teddybear' }
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear') }
+ it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Exec[apt_update]') }
end
context 'with title=list-teddybear' do
let(:title) { 'list-teddybear' }
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list') }
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Exec[apt_update]') }
end
context 'with source' do
let(:params) { { :source => 'puppet:///la/die/dah' } }
it {
- is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
+ is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
:ensure => 'file',
:owner => 'root',
:group => 'root',
context 'with content' do
let(:params) { default_params }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
:ensure => 'file',
:owner => 'root',
:group => 'root',
describe 'with priority=100' do
let(:params) { default_params.merge({ :priority => 100 }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear') }
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') }
end
describe 'with ensure=absent' do
let(:params) { default_params.merge({ :ensure => 'absent' }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
:ensure => 'absent',
})}
end
describe 'with file_perms' do
context "{'owner' => 'roosevelt'}" do
let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
:owner => 'roosevelt',
:group => 'root',
:mode => '0644',
context "'group' => 'roosevelt'}" do
let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
:owner => 'root',
:group => 'roosevelt',
:mode => '0644',
context "'owner' => 'roosevelt'}" do
let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) }
- it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
:owner => 'root',
:group => 'root',
:mode => '0600',
})}
end
+
+ context "'notify_update' => false}" do
+ let(:params) { default_params.merge({ :notify_update => false }) }
+ it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') }
+ it { is_expected.not_to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }
+ end
+
end
end
}
end
- it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').with({
'ensure' => 'present',
}).with_content(/# my_source\ndeb-src wheezy main\n/)
}
}
end
- it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').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/)
}
}
end
- it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').with({
'ensure' => 'present',
}).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
}
}
end
- it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').with({
'ensure' => 'present',
}).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
}
}
end
- it { is_expected.to contain_apt__setting('list-my_source').that_notifies('Exec[apt_update]').with({
+ it { is_expected.to contain_apt__setting('list-my_source').with({
'ensure' => 'absent'
})
}