Skip to content

Commit

Permalink
MODULES-2190 - Fix anchor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Haskel committed Jul 21, 2015
1 parent 5594aa1 commit cd37fc3
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 34 deletions.
12 changes: 5 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

$_update = merge($::apt::update_defaults, $update)
include apt::update
include ::apt::update

validate_hash($purge)
if $purge['sources.list'] {
Expand Down Expand Up @@ -99,7 +99,7 @@
group => root,
mode => '0644',
content => $sources_list_content,
notify => Exec['apt_update'],
notify => Class['apt::update'],
}

file { 'sources.list.d':
Expand All @@ -110,7 +110,7 @@
mode => '0644',
purge => $_purge['sources.list.d'],
recurse => $_purge['sources.list.d'],
notify => Exec['apt_update'],
notify => Class['apt::update'],
}

file { 'preferences':
Expand All @@ -119,7 +119,7 @@
owner => root,
group => root,
mode => '0644',
notify => Exec['apt_update'],
notify => Class['apt::update'],
}

file { 'preferences.d':
Expand All @@ -130,11 +130,9 @@
mode => '0644',
purge => $_purge['preferences.d'],
recurse => $_purge['preferences.d'],
notify => Exec['apt_update'],
notify => Class['apt::update'],
}

anchor { 'apt_first': } -> Class['apt::update'] -> anchor { 'apt_last': }

# manage sources if present
if $sources {
create_resources('apt::source', $sources)
Expand Down
4 changes: 2 additions & 2 deletions manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}",
user => 'root',
logoutput => 'on_failure',
notify => Exec['apt_update'],
notify => Class['apt::update'],
require => $_require,
}

Expand All @@ -57,7 +57,7 @@
else {
file { "${::apt::sources_list_d}/${sources_list_d_filename}":
ensure => 'absent',
notify => Exec['apt_update'],
notify => Class['apt::update'],
}
}
}
2 changes: 1 addition & 1 deletion manifests/setting.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
$_ext = $::apt::params::config_files[$setting_type]['ext']

if $notify_update {
$_notify = Exec['apt_update']
$_notify = Class['apt::update']
} else {
$_notify = undef
}
Expand Down
3 changes: 2 additions & 1 deletion manifests/source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
validate_bool($allow_unsigned)
validate_hash($include)

include 'apt::params'
# This is needed for compat with 1.8.x
include ::apt

$_before = Apt::Setting["list-${title}"]

Expand Down
16 changes: 8 additions & 8 deletions spec/classes/apt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} }

context 'defaults' do
it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({
:ensure => 'file',
:path => '/etc/apt/sources.list',
:owner => 'root',
:group => 'root',
:mode => '0644',
:notify => 'Exec[apt_update]',
:notify => 'Class[Apt::Update]',
})}

it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
it { is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with({
:ensure => 'directory',
:path => '/etc/apt/sources.list.d',
:owner => 'root',
:group => 'root',
:mode => '0644',
:purge => false,
:recurse => false,
:notify => 'Exec[apt_update]',
:notify => 'Class[Apt::Update]',
})}

it { is_expected.to contain_file('preferences').that_notifies('Exec[apt_update]').only_with({
it { is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with({
:ensure => 'file',
:path => '/etc/apt/preferences',
:owner => 'root',
:group => 'root',
:mode => '0644',
:notify => 'Exec[apt_update]',
:notify => 'Class[Apt::Update]',
})}

it { is_expected.to contain_file('preferences.d').that_notifies('Exec[apt_update]').only_with({
it { is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with({
:ensure => 'directory',
:path => '/etc/apt/preferences.d',
:owner => 'root',
:group => 'root',
:mode => '0644',
:purge => false,
:recurse => false,
:notify => 'Exec[apt_update]',
:notify => 'Class[Apt::Update]',
})}

it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
Expand Down
16 changes: 8 additions & 8 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

let(:title) { 'ppa:needs/such.substitution/wow' }
it { is_expected.to_not contain_package('python-software-properties') }
it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({
:environment => [],
:command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
:unless => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
Expand Down Expand Up @@ -57,7 +57,7 @@

let(:title) { 'ppa:needs/such.substitution/wow' }
it { is_expected.to contain_package('software-properties-common') }
it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({
'environment' => [],
'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
Expand Down Expand Up @@ -94,7 +94,7 @@

let(:title) { 'ppa:needs/such.substitution/wow' }
it { is_expected.to_not contain_package('python-software-properties') }
it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with({
'environment' => [],
'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
Expand Down Expand Up @@ -135,7 +135,7 @@
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({
it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
:environment => [],
:command => '/usr/bin/add-apt-repository ppa:foo',
:unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
Expand Down Expand Up @@ -169,7 +169,7 @@
end
let(:title) { 'ppa:foo' }
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({
it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
:environment => ['http_proxy=http://localhost:8080'],
:command => '/usr/bin/add-apt-repository ppa:foo',
:unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
Expand Down Expand Up @@ -203,7 +203,7 @@
end
let(:title) { 'ppa:foo' }
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({
it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
:environment => ['http_proxy=http://localhost:8180'],
:command => '/usr/bin/add-apt-repository ppa:foo',
:unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
Expand Down Expand Up @@ -237,7 +237,7 @@
end
let(:title) { 'ppa:foo' }
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({
it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Class[Apt::Update]').with({
:environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'],
:command => '/usr/bin/add-apt-repository ppa:foo',
:unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
Expand Down Expand Up @@ -267,7 +267,7 @@
:ensure => 'absent'
}
end
it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Class[Apt::Update]').with({
:ensure => 'absent',
})
}
Expand Down
14 changes: 7 additions & 7 deletions spec/defines/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@

context 'with title=conf-teddybear ' do
let(:params) { default_params }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[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').that_notifies('Exec[apt_update]') }
it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Class[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').that_notifies('Exec[apt_update]') }
it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[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').that_notifies('Exec[apt_update]').with({
is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({
:ensure => 'file',
:owner => 'root',
:group => 'root',
Expand All @@ -45,7 +45,7 @@

context 'with content' do
let(:params) { default_params }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({
:ensure => 'file',
:owner => 'root',
:group => 'root',
Expand Down Expand Up @@ -103,12 +103,12 @@

describe 'with priority=100' do
let(:params) { default_params.merge({ :priority => 100 }) }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[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').that_notifies('Exec[apt_update]').with({
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({
:ensure => 'absent',
})}
end
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
}).with_content(/hello.there wheezy main\n/)
}

it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]')}

it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
:ensure => 'present',
:priority => 1001,
Expand Down

0 comments on commit cd37fc3

Please sign in to comment.