Add support for creating pins from main class
This lets you create apt::pin resources as an apt param hash. It also supplies appropriate tests and documentation.
This commit is contained in:
parent
418820adf3
commit
0dce05adae
3 changed files with 27 additions and 1 deletions
|
@ -243,7 +243,9 @@ Main class, includes all other classes.
|
|||
|
||||
* `settings`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
|
||||
|
||||
* `sources`: Creates new `apt::setting` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
|
||||
* `sources`: Creates new `apt::source` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
|
||||
|
||||
* `pins`: Creates new `apt::pin` resources. Valid options: a hash to be passed to the [`create_resources` function](https://docs.puppetlabs.com/references/latest/function.html#createresources). Default: {}.
|
||||
|
||||
* `update`: Configures various update settings. Valid options: a hash made up from the following keys:
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class apt(
|
|||
$sources = {},
|
||||
$keys = {},
|
||||
$ppas = {},
|
||||
$pins = {},
|
||||
$settings = {},
|
||||
) inherits ::apt::params {
|
||||
|
||||
|
@ -66,6 +67,7 @@ class apt(
|
|||
validate_hash($keys)
|
||||
validate_hash($settings)
|
||||
validate_hash($ppas)
|
||||
validate_hash($pins)
|
||||
|
||||
if $_proxy['ensure'] == 'absent' or $_proxy['host'] {
|
||||
apt::setting { 'conf-proxy':
|
||||
|
@ -153,4 +155,9 @@ class apt(
|
|||
if $settings {
|
||||
create_resources('apt::setting', $settings)
|
||||
}
|
||||
|
||||
# manage pins if present
|
||||
if $pins {
|
||||
create_resources('apt::pin', $pins)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,6 +237,23 @@ describe 'apt' do
|
|||
it { is_expected.to contain_apt__setting('pref-banana')}
|
||||
end
|
||||
|
||||
context 'with pins defined on valid osfamily' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:lsbdistcodename => 'precise',
|
||||
:lsbdistid => 'Debian',
|
||||
:puppetversion => Puppet.version,
|
||||
}
|
||||
end
|
||||
let(:params) { { :pins => {
|
||||
'stable' => { 'priority' => 600, 'order' => 50 },
|
||||
'testing' => { 'priority' => 700, 'order' => 100 },
|
||||
} } }
|
||||
|
||||
it { is_expected.to contain_apt__pin('stable') }
|
||||
it { is_expected.to contain_apt__pin('testing') }
|
||||
end
|
||||
|
||||
describe 'failing tests' do
|
||||
context "purge['sources.list']=>'banana'" do
|
||||
let(:params) { { :purge => { 'sources.list' => 'banana' }, } }
|
||||
|
|
Loading…
Reference in a new issue