diff --git a/manifests/init.pp b/manifests/init.pp index 6bda33e92..36331eff8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -63,10 +63,11 @@ $_package_file_name = "${puppet_agent::package_name}-${package_version}-1.${pkg_arch}.pkg.gz" } elsif $::operatingsystemmajrelease == '11' { # Strip letters from development builds. Unique to Solaris 11 packaging. - $_version_without_letters = regsubst($package_version, /[a-zA-Z]/, '', 'G') - $_solaris_version = regsubst($_version_without_letters, /(^-|-$)/, '', 'G') + # Need to pass the regex as strings for Puppet 3 compatibility. + $_version_without_letters = regsubst($package_version, '[a-zA-Z]', '', 'G') + $_package_version = regsubst($_version_without_letters, '(^-|-$)', '', 'G') - $_package_file_name = "${puppet_agent::package_name}@${_solaris_version},5.11-1.${pkg_arch}.p5p" + $_package_file_name = "${puppet_agent::package_name}@${_package_version},5.11-1.${pkg_arch}.p5p" } } elsif $::operatingsystem == 'Darwin' and $::macosx_productversion_major =~ /10\.[9,10,11]/ { $_package_file_name = "${puppet_agent::package_name}-${package_version}-1.osx${$::macosx_productversion_major}.dmg" @@ -90,13 +91,20 @@ $_package_file_name = undef } + # Allow for normalizing package_version for the package provider via _package_version. + # This only needs to be passed through to install, as elsewhere we want to + # use the full version string for comparisons. + if $_package_version == undef { + $_package_version = $package_version + } + class { '::puppet_agent::prepare': package_file_name => $_package_file_name, package_version => $package_version, } -> class { '::puppet_agent::install': package_file_name => $_package_file_name, - package_version => $package_version, + package_version => $_package_version, } contain '::puppet_agent::prepare' diff --git a/spec/classes/puppet_agent_osfamily_solaris_spec.rb b/spec/classes/puppet_agent_osfamily_solaris_spec.rb index 2e45cc717..dd926a6ec 100644 --- a/spec/classes/puppet_agent_osfamily_solaris_spec.rb +++ b/spec/classes/puppet_agent_osfamily_solaris_spec.rb @@ -10,7 +10,11 @@ :clientcert => 'foo.example.vm', } - package_version = '1.2.5' + package_version = '1.2.5.90.g93a35da' + # Strips out strings in the version string on Solaris 11, + # because pkg doesn't accept strings in version numbers. This + # is how developer builds are labelled. + sol11_package_version = '1.2.5.90.9335' pe_version = '2000.0.0' if Puppet.version >= "4.0.0" let(:params) do @@ -50,6 +54,10 @@ Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| package_version end + + # Ensure we get a versionable package provider + pkg = Puppet::Type.type(:package) + pkg.stubs(:defaultprovider).returns(pkg.provider(:pkg)) end context "when Solaris 11 i386" do @@ -65,9 +73,9 @@ it { is_expected.to contain_file('/opt/puppetlabs') } it { is_expected.to contain_file('/opt/puppetlabs/packages') } it do - is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{package_version},5.11-1.i386.p5p").with_ensure('present') - is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{package_version},5.11-1.i386.p5p").with({ - 'source' => "puppet:///pe_packages/#{pe_version}/solaris-11-i386/puppet-agent@#{package_version},5.11-1.i386.p5p", + is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p").with({ + 'ensure' => 'present', + 'source' => "puppet:///pe_packages/#{pe_version}/solaris-11-i386/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p", }) end @@ -75,7 +83,7 @@ is_expected.to contain_exec('puppet_agent remove existing repo').with_command("rm -rf '/etc/puppetlabs/installer/solaris.repo'") is_expected.to contain_exec('puppet_agent create repo').with_command('pkgrepo create /etc/puppetlabs/installer/solaris.repo') is_expected.to contain_exec('puppet_agent set publisher').with_command('pkgrepo set -s /etc/puppetlabs/installer/solaris.repo publisher/prefix=puppetlabs.com') - is_expected.to contain_exec('puppet_agent copy packages').with_command("pkgrecv -s file:///opt/puppetlabs/packages/puppet-agent@1.2.5,5.11-1.i386.p5p -d /etc/puppetlabs/installer/solaris.repo '*'") + is_expected.to contain_exec('puppet_agent copy packages').with_command("pkgrecv -s file:///opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p -d /etc/puppetlabs/installer/solaris.repo '*'") is_expected.to contain_exec('puppet_agent ensure pkgrepo is up-to-date').with_command('pkgrepo refresh -s /etc/puppetlabs/installer/solaris.repo') end @@ -115,7 +123,7 @@ else it do is_expected.not_to contain_transition("remove puppet-agent") - is_expected.to contain_package('puppet-agent').with_ensure(package_version) + is_expected.to contain_package('puppet-agent').with_ensure(sol11_package_version) end end end @@ -134,9 +142,9 @@ it { is_expected.to contain_file('/opt/puppetlabs') } it { is_expected.to contain_file('/opt/puppetlabs/packages') } it do - is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent@1.2.5,5.11-1.sparc.p5p').with_ensure('present') - is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent@1.2.5,5.11-1.sparc.p5p').with({ - 'source' => "puppet:///pe_packages/#{pe_version}/solaris-11-sparc/puppet-agent@#{package_version},5.11-1.sparc.p5p", + is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.sparc.p5p").with({ + 'ensure' => 'present', + 'source' => "puppet:///pe_packages/#{pe_version}/solaris-11-sparc/puppet-agent@#{sol11_package_version},5.11-1.sparc.p5p", }) end @@ -144,7 +152,7 @@ is_expected.to contain_exec('puppet_agent remove existing repo').with_command("rm -rf '/etc/puppetlabs/installer/solaris.repo'") is_expected.to contain_exec('puppet_agent create repo').with_command('pkgrepo create /etc/puppetlabs/installer/solaris.repo') is_expected.to contain_exec('puppet_agent set publisher').with_command('pkgrepo set -s /etc/puppetlabs/installer/solaris.repo publisher/prefix=puppetlabs.com') - is_expected.to contain_exec('puppet_agent copy packages').with_command("pkgrecv -s file:///opt/puppetlabs/packages/puppet-agent@1.2.5,5.11-1.sparc.p5p -d /etc/puppetlabs/installer/solaris.repo '*'") + is_expected.to contain_exec('puppet_agent copy packages').with_command("pkgrecv -s file:///opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.sparc.p5p -d /etc/puppetlabs/installer/solaris.repo '*'") is_expected.to contain_exec('puppet_agent ensure pkgrepo is up-to-date').with_command('pkgrepo refresh -s /etc/puppetlabs/installer/solaris.repo') end @@ -185,7 +193,7 @@ else it do is_expected.not_to contain_transition("remove puppet-agent") - is_expected.to contain_package('puppet-agent').with_ensure(package_version) + is_expected.to contain_package('puppet-agent').with_ensure(sol11_package_version) end end end @@ -203,8 +211,10 @@ it { is_expected.to contain_file('/opt/puppetlabs') } it { is_expected.to contain_file('/opt/puppetlabs/packages') } it do - is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg.gz").with_ensure('present') - is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg.gz").with_source("puppet:///pe_packages/#{pe_version}/solaris-10-i386/puppet-agent-#{package_version}-1.i386.pkg.gz") + is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg.gz").with({ + 'ensure' => 'present', + 'source' => "puppet:///pe_packages/#{pe_version}/solaris-10-i386/puppet-agent-#{package_version}-1.i386.pkg.gz" + }) end it { is_expected.to contain_file('/opt/puppetlabs/packages/solaris-noask').with_source("puppet:///pe_packages/#{pe_version}/solaris-10-i386/solaris-noask") } @@ -283,8 +293,10 @@ it { is_expected.to contain_file('/opt/puppetlabs/packages') } it do - is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.sparc.pkg.gz").with_ensure('present') - is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.sparc.pkg.gz").with_source("puppet:///pe_packages/#{pe_version}/solaris-10-sparc/puppet-agent-#{package_version}-1.sparc.pkg.gz") + is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.sparc.pkg.gz").with({ + 'ensure' => 'present', + 'source' => "puppet:///pe_packages/#{pe_version}/solaris-10-sparc/puppet-agent-#{package_version}-1.sparc.pkg.gz" + }) end it { is_expected.to contain_file('/opt/puppetlabs/packages/solaris-noask').with_source("puppet:///pe_packages/#{pe_version}/solaris-10-sparc/solaris-noask") }