this module already has parameters that let users purge sources.list.d
and preferences.d. It also has resources to create source files in
sources.list.d and "pins" in preferences.d and also has a resource to
create a configuration file in apt.conf.d. however, for some reason it
can't purge apt.conf.d
purging this directory can help users ensure that systems run exactly
with what puppet knows the system should be configured with.
* Your system's `preferences` file and `preferences.d` directory
* Your system's `sources.list` file and `sources.list.d` directory
* Your system's `preferences` file and `preferences.d` directory
* Your system's `sources.list` file and `sources.list.d` directory
+* Your system's `apt.conf.d` directory
* System repositories
* Authentication keys
* System repositories
* Authentication keys
-**Note:** This module offers `purge` parameters which, if set to `true`, **destroy** any configuration on the node's `sources.list(.d)` and `preferences(.d)` that you haven't declared through Puppet. The default for these parameters is `false`.
+**Note:** This module offers `purge` parameters which, if set to `true`, **destroy** any configuration on the node's `sources.list(.d)`, `preferences(.d)` and `apt.conf.d` that you haven't declared through Puppet. The default for these parameters is `false`.
<a id="beginning-with-apt"></a>
### Beginning with apt
<a id="beginning-with-apt"></a>
### Beginning with apt
String $conf_d = $apt::params::conf_d,
String $preferences = $apt::params::preferences,
String $preferences_d = $apt::params::preferences_d,
String $conf_d = $apt::params::conf_d,
String $preferences = $apt::params::preferences,
String $preferences_d = $apt::params::preferences_d,
+ String $apt_conf_d = $apt::params::apt_conf_d,
Hash $config_files = $apt::params::config_files,
Hash $source_key_defaults = $apt::params::source_key_defaults,
) inherits apt::params {
Hash $config_files = $apt::params::config_files,
Hash $source_key_defaults = $apt::params::source_key_defaults,
) inherits apt::params {
if $purge['preferences.d'] {
assert_type(Boolean, $purge['preferences.d'])
}
if $purge['preferences.d'] {
assert_type(Boolean, $purge['preferences.d'])
}
+ if $purge['apt.conf.d'] {
+ assert_type(Boolean, $purge['apt.conf.d'])
+ }
$_purge = merge($::apt::purge_defaults, $purge)
$_proxy = merge($apt::proxy_defaults, $proxy)
$_purge = merge($::apt::purge_defaults, $purge)
$_proxy = merge($apt::proxy_defaults, $proxy)
notify => Class['apt::update'],
}
notify => Class['apt::update'],
}
+ file { 'apt.conf.d':
+ ensure => directory,
+ path => $::apt::apt_conf_d,
+ owner => root,
+ group => root,
+ mode => '0644',
+ purge => $_purge['apt.conf.d'],
+ recurse => $_purge['apt.conf.d'],
+ notify => Class['apt::update'],
+ }
+
if $confs {
create_resources('apt::conf', $confs)
}
if $confs {
create_resources('apt::conf', $confs)
}
$conf_d = "${root}/apt.conf.d"
$preferences = "${root}/preferences"
$preferences_d = "${root}/preferences.d"
$conf_d = "${root}/apt.conf.d"
$preferences = "${root}/preferences"
$preferences_d = "${root}/preferences.d"
+ $apt_conf_d = "${root}/apt.conf.d"
$keyserver = 'keyserver.ubuntu.com'
$confs = {}
$update = {}
$keyserver = 'keyserver.ubuntu.com'
$confs = {}
$update = {}
'sources.list.d' => false,
'preferences' => false,
'preferences.d' => false,
'sources.list.d' => false,
'preferences' => false,
'preferences.d' => false,
}
$source_key_defaults = {
}
$source_key_defaults = {
'sources.list.d' => true,
'preferences' => true,
'preferences.d' => true,
'sources.list.d' => true,
'preferences' => true,
'preferences.d' => true,
},
sources => $sources,
}
},
sources => $sources,
}
recurse: false,
notify: 'Class[Apt::Update]' }
recurse: false,
notify: 'Class[Apt::Update]' }
+apt_conf_d = { ensure: 'directory',
+ path: '/etc/apt/apt.conf.d',
+ owner: 'root',
+ group: 'root',
+ mode: '0644',
+ purge: false,
+ recurse: false,
+ notify: 'Class[Apt::Update]' }
+
describe 'apt' do
let(:facts) do
{
describe 'apt' do
let(:facts) do
{
is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
}
is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d)
}
+ it {
+ is_expected.to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d)
+ }
+
it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') }
it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') }
it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
{
update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
purge: { 'sources.list' => false, 'sources.list.d' => false,
{
update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
purge: { 'sources.list' => false, 'sources.list.d' => false,
- 'preferences' => false, 'preferences.d' => false },
+ 'preferences' => false, 'preferences.d' => false,
+ 'apt.conf.d' => false },
+ it {
+ is_expected.to contain_file('apt.conf.d').with(purge: false,
+ recurse: false)
+ }
+
it {
is_expected.to contain_exec('apt_update').with(refreshonly: false,
timeout: 1,
it {
is_expected.to contain_exec('apt_update').with(refreshonly: false,
timeout: 1,
is_expected.to raise_error(Puppet::Error)
end
end
is_expected.to raise_error(Puppet::Error)
end
end
+
+ context "with purge['apt.conf.d']=>'banana'" do
+ let(:params) { { purge: { 'apt.conf.d' => 'banana' } } }
+
+ it do
+ is_expected.to raise_error(Puppet::Error)
+ end
+ end