Skip to content

Commit

Permalink
MODULES-2873 - Avoid duplicate package resources when package_manage …
Browse files Browse the repository at this point in the history
…=> true
  • Loading branch information
werekraken committed Feb 2, 2016
1 parent 5e6ba08 commit 08c8b58
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

if $ensure == 'present' {
if $package_manage {
package { $package_name: }
ensure_packages($package_name)

$_require = [File['sources.list.d'], Package[$package_name]]
} else {
Expand Down
40 changes: 40 additions & 0 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,46 @@
}
end

describe 'package_manage => true, multiple ppas, MODULES-2873' do
let :pre_condition do
'class { "apt": }
apt::ppa {"ppa:foo":
package_manage => true
}'
end
let :facts do
{
:lsbdistrelease => '11.04',
:lsbdistcodename => 'natty',
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:puppetversion => Puppet.version,
}
end
let :params do
{
:package_manage => true,
}
end

let(:title) { 'ppa:bar' }
it { is_expected.to contain_package('python-software-properties') }
it { is_expected.to contain_exec('add-apt-repository-ppa:bar').that_notifies('Class[Apt::Update]').with({
'environment' => [],
'command' => '/usr/bin/add-apt-repository -y ppa:bar',
'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/bar-natty.list',
'user' => 'root',
'logoutput' => 'on_failure',
})
}

it { is_expected.to contain_file('/etc/apt/sources.list.d/bar-natty.list').that_requires('Exec[add-apt-repository-ppa:bar]').with({
'ensure' => 'file',
})
}
end

describe 'package_manage => false' do
let :pre_condition do
'class { "apt": }'
Expand Down

0 comments on commit 08c8b58

Please sign in to comment.