Skip to content

Commit

Permalink
Merge pull request #261 from MikaelSmith/try-upgrade
Browse files Browse the repository at this point in the history
(MODULES-5979) Use rpm upgrade for puppet-agent upgrades
  • Loading branch information
highb authored Nov 10, 2017
2 parents eb8a19c + 114bb32 commit 2d749e6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 55 deletions.
32 changes: 19 additions & 13 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,31 @@
$old_packages = (versioncmp("${::clientversion}", '4.0.0') < 0)

if ($::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10') or $::operatingsystem == 'AIX' {
contain puppet_agent::install::remove_packages

exec { 'replace puppet.conf removed by package removal':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
command => "cp ${puppet_agent::params::confdir}/puppet.conf.rpmsave ${puppet_agent::params::config}",
creates => $puppet_agent::params::config,
require => Class['puppet_agent::install::remove_packages'],
before => Package[$puppet_agent::package_name],
logoutput => 'on_failure',
}

$_install_options = $::operatingsystem ? {
'AIX' => concat(['--ignoreos'],$install_options),
default => $install_options
}

# package provider does not provide 'versionable'
if $old_packages {
contain puppet_agent::install::remove_packages

exec { 'replace puppet.conf removed by package removal':
path => '/bin:/usr/bin:/sbin:/usr/sbin',
command => "cp ${puppet_agent::params::confdir}/puppet.conf.rpmsave ${puppet_agent::params::config}",
creates => $puppet_agent::params::config,
require => Class['puppet_agent::install::remove_packages'],
before => Package[$puppet_agent::package_name],
logoutput => 'on_failure',
}

# package provider does not provide 'versionable'
$ensure = 'present'
} else {
$ensure = $package_version
}

package { $::puppet_agent::package_name:
ensure => 'present',
ensure => $ensure,
provider => 'rpm',
source => "/opt/puppetlabs/packages/${package_file_name}",
install_options => $_install_options,
Expand Down
24 changes: 10 additions & 14 deletions spec/classes/puppet_agent_osfamily_aix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end

package_version = '1.2.5'
package_ensure = 'present'
package_ensure = Puppet.version < "4.0.0" ? 'present' : package_version
let(:params) do
{
:package_version => package_version
Expand Down Expand Up @@ -45,11 +45,11 @@
if Puppet.version < "4.0.0"
it { is_expected.to contain_file('/etc/puppetlabs/puppet') }
it { is_expected.to contain_file('/etc/puppetlabs/puppet/puppet.conf') }
end

it do
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf')
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf')
it do
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf')
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf')
end
end

it { is_expected.to contain_file('/opt/puppetlabs') }
Expand Down Expand Up @@ -96,15 +96,11 @@
'pe-ruby-ldap',
].each do |package|
it do
if Puppet.version < "4.0.0"
else
is_expected.to contain_transition("remove #{package}").with(
:attributes => {
'ensure' => 'absent',
'uninstall_options' => '--nodeps',
'provider' => 'rpm',
})
end
is_expected.to contain_package(package).with({
'ensure' => 'absent',
'uninstall_options' => '--nodeps',
'provider' => 'rpm',
})
end
end
end
Expand Down
37 changes: 9 additions & 28 deletions spec/classes/puppet_agent_osfamily_suse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@
})
end

it { is_expected.to contain_class("puppet_agent::prepare::package") }

it do
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf')
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf')
end

it { is_expected.to contain_file('/opt/puppetlabs') }
it { is_expected.to contain_file('/opt/puppetlabs/packages') }
it do
Expand All @@ -79,7 +72,14 @@
it { is_expected.to contain_class("puppet_agent::osfamily::suse") }

if Puppet.version < "4.0.0"
it { is_expected.to contain_class("puppet_agent::prepare::package") }

it do
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf')
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf')
end

it { is_expected.to contain_class("puppet_agent::install::remove_packages") }
[
'pe-augeas',
'pe-mcollective-common',
Expand All @@ -106,31 +106,12 @@
is_expected.to contain_package(package).with_provider('rpm')
end
end
it { is_expected.to contain_package('puppet-agent').with_ensure('present') }
else
context 'aio_agent_version is out of date' do
let(:facts) do
facts.merge({
:operatingsystemmajrelease => '10',
:platform_tag => "sles-10-x86_64",
:architecture => "x86_64",
:aio_agent_version => '1.0.0'
})
end

it { is_expected.to contain_class("puppet_agent::install::remove_packages") }
it do
is_expected.to contain_transition('remove puppet-agent').with_attributes(
'ensure' => 'absent',
'uninstall_options' => '--nodeps',
'provider' => 'rpm')
end
end

it { is_expected.not_to contain_transition("remove puppet-agent") }
it { is_expected.to contain_package('puppet-agent').with_ensure('1.2.5') }
end

it do
is_expected.to contain_package('puppet-agent').with_ensure('present')
is_expected.to contain_package('puppet-agent').with_provider('rpm')
is_expected.to contain_package('puppet-agent').with_source('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.sles10.x86_64.rpm')
end
Expand Down

0 comments on commit 2d749e6

Please sign in to comment.