Merge pull request #222 from ajroetker/maint/handle_terminus_package_upgrades

(maint) Handle terminus to termini package upgrades
This commit is contained in:
Ryan Senior 2016-03-14 14:06:22 -05:00
commit 02c05c4a57
3 changed files with 48 additions and 3 deletions

View file

@ -1,7 +1,8 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"
group :development, :test do
gem 'rake'
# Pinning `rake` because `v11` doesn't support Ruby 1.8.7
gem 'rake', '10.5.0'
gem 'puppetlabs_spec_helper', :require => false
# Pinning due to bug in newer rspec with Ruby 1.8.7
gem 'rspec-core', '3.1.7'

View file

@ -29,6 +29,35 @@ class puppetdb::master::config (
$restart_puppet = true,
) inherits puppetdb::params {
# **WARNING**: Ugly hack to work around a yum bug with metadata parsing. This
# should not be copied, replicated or even looked at. In short, never rename
# your packages...
#
# With `yum` we can't have the termini package override the terminus package
# because that would prevent users from installing v2.3 of the terminus in
# PC1. We tried using a dummy terminus-3 metadata package which pulled in
# termini-3.latest as a dependency and put a requires terminus >= 3, <4. The
# idea was that doing `yum install puppetdb-termini-3.x.y-1.el7` would pull up
# the terminus package to the dummy 3 version, but `yum` has a bug which
# requires that both the dummy package and termini be installed in the same
# transaction, i.e. `yum install puppetdb-termini-3.x.y-1.el7
# puppetdb-terminus-3` which is impossible to do via Puppet.
#
# This will orphan some old terminus files (from pre-puppet-agent, i.e. puppet
# 3.x) that are orphaned as part of the Puppet 3 to Puppet 4 upgrade anyways
# and some of the new terminus files temporarily. If this exec fails all you
# need to do is reinstall whatever 2.3 version of the terminus was already
# installed to revert the change.
if !($puppetdb::params::puppetdb_version in ['present','absent'])
and versioncmp($puppetdb::params::puppetdb_version, '3.0.0') >= 0
and $::osfamily in ['RedHat','Suse'] {
exec { 'Remove puppetdb-terminus metadata for upgrade':
command => 'rpm -e --justdb puppetdb-terminus',
path => '/sbin/:/bin/',
onlyif => 'rpm -q puppetdb-terminus',
before => Package[$terminus_package],
}
}
package { $terminus_package:
ensure => $puppetdb::params::puppetdb_version,

View file

@ -62,18 +62,33 @@ describe 'puppetdb::master::config', :type => :class do
:use_ssl => 'false')}
end
context 'when using default values' do
it { should contain_package('puppetdb-termini').with( :ensure => 'present' )}
it { should contain_puppetdb_conn_validator('puppetdb_conn').with(:test_url => '/pdb/meta/v1/version')}
end
context 'when using an older puppetdb version' do
let (:pre_condition) { 'class { "puppetdb::globals": version => "2.2.0", }' }
it { should contain_package('puppetdb-terminus').with( :ensure => '2.2.0' )}
it { should contain_puppetdb_conn_validator('puppetdb_conn').with(:test_url => '/v3/version')}
end
context 'when upgrading to from v2 to v3 of PuppetDB on RedHat' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.0',
:kernel => 'Linux',
:concat_basedir => '/var/lib/puppet/concat',
}
end
let (:pre_condition) { 'class { "puppetdb::globals": version => "3.1.1-1.el7", }' }
it { should contain_exec('Remove puppetdb-terminus metadata for upgrade').with(:command => 'rpm -e --justdb puppetdb-terminus')}
end
end
end