From: David Schmitt Date: Mon, 7 Sep 2015 11:11:31 +0000 (+0100) Subject: Merge pull request #564 from rfdrake/apt_pin X-Git-Tag: 2.2.0~1 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2778c8588e2df11e16a20075fedd9b9a93f6dbd5;hp=ff37b84980cbaa92b7e12b26701faa49402a2916;p=puppet-modules%2Fpuppetlabs-apt.git Merge pull request #564 from rfdrake/apt_pin Add support for creating pins from main class --- diff --git a/README.md b/README.md index b2b5546..1c9591d 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/manifests/init.pp b/manifests/init.pp index b9087cf..2e82502 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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) + } } diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 7578d2e..5aded56 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -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' }, } }