From 911c4de90fc493e4449d42a1ed6ea0e40925b330 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Mon, 23 Mar 2015 13:55:13 -0400 Subject: [PATCH] (MODULES-1156, MODULES-769) Remove unnecessary anchors `apt::ppa` and `apt::setting` don't actually include `apt::update` so anchors are unnecessary. Move `apt` to use contain instead of anchors, since it wasn't anchoring properly anyways. Update the tests to make sure it can have settings and ppas depending on each other without cycles. --- manifests/init.pp | 5 +---- manifests/ppa.pp | 5 ----- manifests/setting.pp | 6 ------ spec/defines/ppa_spec.rb | 14 ++++++++++++-- spec/defines/setting_spec.rb | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 453df31..140e171 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -133,10 +133,7 @@ class apt( notify => Exec['apt_update'], } - # Need anchor to provide containment for dependencies. - anchor { 'apt::update': - require => Class['apt::update'], - } + contain 'apt::update' # manage sources if present if $sources { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index 5fc7f3c..5d4c890 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -60,9 +60,4 @@ define apt::ppa( notify => Exec['apt_update'], } } - - # Need anchor to provide containment for dependencies. - anchor { "apt::ppa::${name}": - require => Class['apt::update'], - } } diff --git a/manifests/setting.pp b/manifests/setting.pp index bc0e15a..ab84460 100644 --- a/manifests/setting.pp +++ b/manifests/setting.pp @@ -60,10 +60,4 @@ define apt::setting ( source => $source, notify => $_notify, } - - if $notify_update { - anchor { "apt::setting::${name}": - require => Class['apt::update'] - } - } } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 7c0d072..30a09a4 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -27,10 +27,18 @@ describe 'apt::ppa' do } end - describe 'apt included, no proxy' do + describe 'ppa depending on ppa, MODULES-1156' do let :pre_condition do 'class { "apt": }' end + end + + describe 'apt included, no proxy' do + let :pre_condition do + 'class { "apt": } + apt::ppa { "ppa:foo2": } + ' + end let :facts do { :lsbdistrelease => '14.04', @@ -42,11 +50,13 @@ describe 'apt::ppa' do end let :params do { - :options => '', + :options => '', :package_manage => true, + :require => 'Apt::Ppa[ppa:foo2]', } end let(:title) { 'ppa:foo' } + it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({ :environment => [], diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index d69ae45..6f09f9c 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -55,6 +55,21 @@ describe 'apt::setting' do end end + describe 'settings requiring settings, MODULES-769' do + let(:pre_condition) do + 'class { "apt": } + apt::setting { "list-teddybear": content => "foo" } + ' + end + let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } } + let(:title) { 'conf-teddybear' } + let(:default_params) { { :content => 'di' } } + + let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) } + + it { is_expected.to compile.with_all_deps } + end + describe 'when trying to pull one over' do context 'with source and content' do let(:params) { default_params.merge({ :source => 'la' }) } -- 2.32.3