Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
add work around for broken package yum provider on RedHat
Browse files Browse the repository at this point in the history
As of puppet 3.4.2, the yum provider for the package type does not
handle 'purged' correctly and shows activity on every run.
  • Loading branch information
Joshua Hoblitt committed Jan 29, 2014
1 parent bb7c059 commit dbb1c5e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 25 deletions.
13 changes: 12 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@

validate_re($ensure, '^present$|^absent$|^latest$|^purged$')

# As of puppet 3.4.2, the yum provider for the package type does not handle
# 'purged' correctly and shows activity on every run.
if $::osfamily == 'RedHat' {
$safe_ensure = $ensure ? {
'purged' => 'absent',
default => $ensure,
}
} else {
$safe_ensure = $ensure
}

package { $package_name:
ensure => $ensure,
ensure => $safe_ensure,
}

case $ensure {
Expand Down
58 changes: 34 additions & 24 deletions spec/classes/port389_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
describe 'on osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

it('should import') { should contain_class('port389') }

it('should include package dependency') { should contain_package('httpd') }
[
redhat_packages = [
'389-admin',
'389-admin-console',
'389-admin-console-doc',
Expand All @@ -35,25 +32,32 @@
'389-ds-console-doc',
'389-dsgw',
#'389-dsgw-debuginfo',
].each do |pkg|
it('should include package') { should contain_package(pkg) }
end
]

it 'should manage setup dir' do
should contain_file('/var/lib/dirsrv/setup').with({
:ensure => 'directory',
:owner => 'nobody',
:group => 'nobody',
:mode => '0700',
})
end
context 'param defaults' do
it_should_behave_like 'been_tuned'
it('should include package dependency') { should contain_package('httpd') }
redhat_packages.each do |pkg|
it('should include package') { should contain_package(pkg) }
end
it 'should manage setup dir' do
should contain_file('/var/lib/dirsrv/setup').with({
:ensure => 'directory',
:owner => 'nobody',
:group => 'nobody',
:mode => '0700',
})
end
end # param defaults

context 'ensure =>' do
context 'present' do
let(:params) {{ :ensure => 'present' }}

it { should contain_class('port389::tune') }
it { should contain_class('port389::install').with_ensure('present') }
it_should_behave_like 'been_tuned'
redhat_packages.each do |pkg|
it { should contain_package(pkg).with_ensure('present') }
end
it do
should contain_file('/var/lib/dirsrv/setup').with({
:ensure => 'directory',
Expand All @@ -67,8 +71,10 @@
context 'latest' do
let(:params) {{ :ensure => 'latest' }}

it { should contain_class('port389::tune') }
it { should contain_class('port389::install').with_ensure('latest') }
it_should_behave_like 'been_tuned'
redhat_packages.each do |pkg|
it { should contain_package(pkg).with_ensure('latest') }
end
it do
should contain_file('/var/lib/dirsrv/setup').with({
:ensure => 'directory',
Expand All @@ -83,15 +89,19 @@
let(:params) {{ :ensure => 'absent' }}

it { should_not contain_class('port389::tune') }
it { should contain_class('port389::install').with_ensure('absent') }
redhat_packages.each do |pkg|
it { should contain_package(pkg).with_ensure('absent') }
end
it { should_not contain_file('/var/lib/dirsrv/setup') }
end

context 'purged' do
let(:params) {{ :ensure => 'purged' }}

it { should_not contain_class('port389::tune') }
it { should contain_class('port389::install').with_ensure('purged') }
redhat_packages.each do |pkg|
it { should contain_package(pkg).with_ensure('absent') }
end
it do
should contain_file('/var/lib/dirsrv/setup').with({
:ensure => 'absent',
Expand Down Expand Up @@ -123,7 +133,7 @@

it 'should fail' do
expect {
should contain_class('port389')
should compile
}.to raise_error(/"foo" does not match/)
end
end
Expand All @@ -148,7 +158,7 @@

it 'should fail' do
expect {
should contain_class('port389')
should compile
}.to raise_error(/is not a boolean/)
end
end
Expand All @@ -159,7 +169,7 @@
let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Debian' }}

it 'should fail' do
expect { should contain_class('port389') }.
expect { should compile }.
to raise_error(Puppet::Error, /not supported on Debian/)
end
end # on an unsupported osfamily
Expand Down

0 comments on commit dbb1c5e

Please sign in to comment.