Skip to content

Commit

Permalink
Merge pull request #93 from MikaelSmith/feature/master/pe-12299-add-s…
Browse files Browse the repository at this point in the history
…olaris-11

(PE-12299) Add Solaris 11 support
  • Loading branch information
highb committed Apr 4, 2016
2 parents 88cb9e6 + 46f2ee5 commit e7415ac
Show file tree
Hide file tree
Showing 13 changed files with 412 additions and 71 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group :test do
gem 'rspec-puppet', '~> 2.2'
gem 'puppetlabs_spec_helper', '~> 0.10'
gem 'metadata-json-lint', '~> 0.0'
gem 'rspec-puppet-facts', '~> 0.10'
gem 'rspec-puppet-facts', '~> 1.3'
end

group :system_tests do
Expand Down
14 changes: 14 additions & 0 deletions files/solaris_start_puppet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

puppet_pid=$1
while $(kill -0 ${puppet_pid:?}); do
sleep 5
done

function start_service() {
service="${1:?}"
/opt/puppetlabs/bin/puppet resource service "${service:?}" ensure=running enable=true
}

start_service puppet
start_service mcollective
48 changes: 27 additions & 21 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
# [package_name]
# The package to upgrade to, i.e. `puppet-agent`.
# [package_version]
# The package version to upgrade to. Defaults to undef, meaning only upgrade from Puppet < 4.0.
# The package version to upgrade to. When upgrading from Puppet < 4.0, defaults to
# the puppet master's latest supported version if compiled with a PE master or
# undef otherwise (meaning get the latest Open Source release). Explicitly specify
# a version to upgrade from puppet-agent packages (implying Puppet >= 4.0).
# [service_names]
# An array of services to start, normally `puppet` and `mcollective`.
# None will be started if the array is empty.
Expand All @@ -28,22 +31,16 @@
$collection = 'PC1',
$is_pe = $::puppet_agent::params::_is_pe,
$package_name = $::puppet_agent::params::package_name,
$package_version = undef,
$package_version = $::puppet_agent::params::package_version,
$service_names = $::puppet_agent::params::service_names,
$source = $::puppet_agent::params::_source,
) inherits ::puppet_agent::params {

validate_re($arch, ['^x86$','^x64$','^i386$','^i86pc$','^amd64$','^x86_64$','^power$','^sun4[uv]$','PowerPC_POWER'])

if ($package_version == undef and $puppet_agent::params::master_agent_version != undef and versioncmp("${::clientversion}", '4.0.0') < 0) {
$_package_version = $puppet_agent::params::master_agent_version
} else {
$_package_version = $package_version
}

if $_package_version == undef and versioncmp("${::clientversion}", '4.0.0') >= 0 {
if $package_version == undef and versioncmp("${::clientversion}", '4.0.0') >= 0 {
info('puppet_agent performs no actions if a package_version is not specified on Puppet 4')
} elsif $_package_version == undef and $is_pe {
} elsif $package_version == undef and $is_pe {
info("puppet_agent performs no actions if the master's agent version cannot be determed on PE 3.x")
} else {
if $package_version != undef and $package_version !~ /^\d+\.\d+\.\d+([.-]?\d*|\.\d+\.g[0-9a-f]+)$/ {
Expand All @@ -55,18 +52,27 @@
}

if $::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10' {
$_package_file_name = "${puppet_agent::package_name}-${_package_version}-1.sles10.${::architecture}.rpm"
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' {
if $arch =~ /^sun4[uv]$/ {
$_package_file_name = "${puppet_agent::package_name}-${_package_version}-1.sparc.pkg.gz"
} else {
$_package_file_name = "${puppet_agent::package_name}-${_package_version}-1.i386.pkg.gz"
$_package_file_name = "${puppet_agent::package_name}-${package_version}-1.sles10.${::architecture}.rpm"
} elsif $::operatingsystem == 'Solaris' {
$pkg_arch = $arch ? {
/^sun4[uv]$/ => 'sparc',
default => 'i386',
}

if $::operatingsystemmajrelease == '10' {
$_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')

$_package_file_name = "${puppet_agent::package_name}@${_solaris_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"
$_package_file_name = "${puppet_agent::package_name}-${package_version}-1.osx${$::macosx_productversion_major}.dmg"
} elsif $::operatingsystem == 'aix' and $::architecture =~ /PowerPC_POWER[5,6,7]/ {
$aix_ver_number = regsubst($::platform_tag,'aix-(\d+\.\d+)-power','\1')
$_package_file_name = "${puppet_agent::package_name}-${_package_version}-1.aix${aix_ver_number}.ppc.rpm"
$_package_file_name = "${puppet_agent::package_name}-${package_version}-1.aix${aix_ver_number}.ppc.rpm"
} elsif $::osfamily == 'windows' {
$_arch = $::kernelmajversion ?{
/^5\.\d+/ => 'x86', # x64 is never allowed on windows 2003
Expand All @@ -75,8 +81,8 @@

if $is_pe {
$_package_file_name = "${package_name}-${_arch}.msi"
} elsif $_package_version != undef {
$_package_file_name = "${package_name}-${_arch}-${_package_version}.msi"
} elsif $package_version != undef {
$_package_file_name = "${package_name}-${_arch}-${package_version}.msi"
} else {
$_package_file_name = "${package_name}-${_arch}-latest.msi"
}
Expand All @@ -89,7 +95,7 @@
} ->
class { '::puppet_agent::install':
package_file_name => $_package_file_name,
package_version => $_package_version,
package_version => $package_version,
}

contain '::puppet_agent::prepare'
Expand Down
25 changes: 24 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
) {
assert_private()

$old_packages = (versioncmp("${::clientversion}", '4.0.0') < 0)

if ($::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10') or ($::operatingsystem == 'AIX' and $::architecture =~ /PowerPC_POWER[5,6,7]/) {
contain puppet_agent::install::remove_packages

Expand All @@ -41,6 +43,27 @@
source => "/opt/puppetlabs/packages/${_unzipped_package_name}",
require => Class['puppet_agent::install::remove_packages'],
}
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' and $old_packages {
# Updating from PE 3.x requires removing all the old packages before installing the puppet-agent package.
# After puppet-agent is installed, we can use 'pkg update' for future upgrades.
contain puppet_agent::install::remove_packages

exec { 'puppet_agent restore /etc/puppetlabs':
command => 'cp -r /tmp/puppet_agent/puppetlabs /etc',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
require => Class['puppet_agent::install::remove_packages'],
}

exec { 'puppet_agent post-install restore /etc/puppetlabs':
command => 'cp -r /tmp/puppet_agent/puppetlabs /etc',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
refreshonly => true,
}

$_package_options = {
require => Exec['puppet_agent restore /etc/puppetlabs'],
notify => Exec['puppet_agent post-install restore /etc/puppetlabs'],
}
} elsif $::operatingsystem == 'Darwin' and $::macosx_productversion_major =~ /10\.[9,10,11]/ {
contain puppet_agent::install::remove_packages

Expand All @@ -67,7 +90,7 @@
}
}
}
} elsif ($::osfamily == 'Solaris' and $::operatingsystemmajrelease == '10') or $::osfamily == 'Darwin' or $::osfamily == 'AIX' or ($::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10') {
} elsif ($::osfamily == 'Solaris' and ($::operatingsystemmajrelease == '10' or $old_packages)) or $::osfamily == 'Darwin' or $::osfamily == 'AIX' or ($::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10') {
# Solaris 10/OSX/AIX/SLES 10 package provider does not provide 'versionable'
# Package is removed above, then re-added as the new version here.
package { $::puppet_agent::package_name:
Expand Down
72 changes: 67 additions & 5 deletions manifests/install/remove_packages.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
'Solaris' => {
ensure => 'absent',
adminfile => '/opt/puppetlabs/packages/solaris-noask',
adminfile => '/opt/puppetlabs/packages/solaris-noask',
},
default => {
ensure => 'absent',
Expand All @@ -35,8 +35,8 @@
if versioncmp("${::clientversion}", '4.0.0') < 0 {
# We only need to remove these packages if we are transitioning from PE
# versions that are pre AIO.
$packages = $::operatingsystem ? {
'Solaris' => [
if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' {
$packages = [
'PUPpuppet',
'PUPaugeas',
'PUPdeep-merge',
Expand All @@ -51,8 +51,70 @@
'PUPruby-rgen',
'PUPruby-shadow',
'PUPstomp',
],
default => [
]
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' {
$packages = [
'pe-mcollective',
'pe-mcollective-common',
'pe-virt-what',
'pe-libldap',
'pe-deep-merge',
'pe-ruby-ldap',
'pe-ruby-augeas',
'pe-ruby-shadow',
'pe-puppet',
'pe-facter',
]
package { 'pe-augeas':
ensure => absent,
require => Package['pe-ruby-augeas'],
}
package { 'pe-stomp':
ensure => absent,
require => Package['pe-mcollective'],
}
package { ['pe-hiera', 'pe-ruby-rgen']:
ensure => absent,
require => Package['pe-puppet'],
}
package { 'pe-ruby':
ensure => absent,
require => Package[
'pe-hiera',
'pe-deep-merge',
'pe-ruby-rgen',
'pe-stomp',
'pe-ruby-shadow',
'pe-puppet',
'pe-mcollective',
'pe-facter',
'pe-facter',
'pe-ruby-augeas'
]
}
package { ['pe-openssl', 'pe-libyaml']:
ensure => absent,
require => Package['pe-ruby'],
}
package { 'pe-puppet-enterprise-release':
ensure => absent,
require => Package[
'pe-hiera',
'pe-stomp',
'pe-deep-merge',
'pe-libyaml',
'pe-ruby',
'pe-ruby-shadow',
'pe-augeas',
'pe-puppet',
'pe-ruby-rgen',
'pe-facter',
'pe-mcollective',
'pe-ruby-augeas'
],
}
} else {
$packages = [
'pe-augeas',
'pe-mcollective-common',
'pe-rubygem-deep-merge',
Expand Down
72 changes: 72 additions & 0 deletions manifests/osfamily/solaris.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,78 @@
source => "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/solaris-noask",
}
}
'11': {
class { 'puppet_agent::prepare::package':
package_file_name => $package_file_name,
}
contain puppet_agent::prepare::package

$pkgrepo_dir = '/etc/puppetlabs/installer/solaris.repo'
$publisher = 'puppetlabs.com'
$arch = $::architecture ? {
/^sun4[uv]$/ => 'sparc',
default => 'i386',
}
$pkg_name = basename($package_file_name, ".${arch}.p5p")

exec { 'puppet_agent remove existing repo':
command => "rm -rf '${pkgrepo_dir}'",
path => '/bin:/usr/bin:/sbin:/usr/sbin',
onlyif => "test -d ${pkgrepo_dir}",
logoutput => 'on_failure',
unless => "pkgrepo list -p ${publisher} -s ${pkgrepo_dir} ${pkg_name}",
} ~>
exec { 'puppet_agent create repo':
command => "pkgrepo create ${pkgrepo_dir}",
path => '/bin:/usr/bin:/sbin:/usr/sbin',
unless => "test -f ${pkgrepo_dir}/pkg5.repository",
logoutput => 'on_failure',
refreshonly => true,
} ~>
exec { 'puppet_agent set publisher':
command => "pkgrepo set -s ${pkgrepo_dir} publisher/prefix=${publisher}",
path => '/bin:/usr/bin:/sbin:/usr/sbin',
logoutput => 'on_failure',
refreshonly => true,
} ~>
exec { 'puppet_agent ensure pkgrepo is up-to-date':
command => "pkgrepo refresh -s ${pkgrepo_dir}",
path => '/bin:/usr/bin:/sbin:/usr/sbin',
logoutput => 'on_failure',
refreshonly => true,
} ~>
exec { 'puppet_agent copy packages':
command => "pkgrecv -s file:///opt/puppetlabs/packages/${package_file_name} -d ${pkgrepo_dir} '*'",
path => '/bin:/usr/bin:/sbin:/usr/sbin',
logoutput => 'on_failure',
refreshonly => true,
} ~>
# Make sure the pkg publishers are all available. Broken
# publisher entries will stop the installation process.
# This must happen before removing any packages.
# We rely on the puppetlabs.com publisher previously being
# setup (during the initial install).
exec { 'puppet_agent ensure pkg publishers are available':
command => "pkg refresh ${publisher}",
path => '/bin:/usr/bin:/sbin:/usr/sbin',
logoutput => 'on_failure',
refreshonly => true,
}

if versioncmp("${::clientversion}", '4.0.0') < 0 {
# Backup user configuration because solaris 11 will blow away
# /etc/puppetlabs/ when uninstalling the pe-* modules.
file { '/tmp/puppet_agent/':
ensure => directory,
} ->
exec { 'puppet_agent backup /etc/puppetlabs/':
command => 'cp -r /etc/puppetlabs/ /tmp/puppet_agent/',
require => Exec['puppet_agent copy packages'],
path => '/bin:/usr/bin:/sbin:/usr/sbin',
}
}

}
default: {
fail("${::operatingsystem} ${::operatingsystemmajrelease} not supported")
}
Expand Down
14 changes: 11 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
}
}

$package_name = 'puppet-agent'

case $::osfamily {
'RedHat', 'Debian', 'Suse', 'Solaris', 'Darwin', 'AIX': {
$package_name = 'puppet-agent'
$service_names = ['puppet', 'mcollective']
if !($::osfamily == 'Solaris' and $::operatingsystemmajrelease == '11') {
$service_names = ['puppet', 'mcollective']
}

$local_puppet_dir = '/opt/puppetlabs'
$local_packages_dir = "${local_puppet_dir}/packages"
Expand All @@ -46,7 +49,6 @@
$group = 0
}
'windows' : {
$package_name = 'puppet-agent'
$service_names = ['puppet', 'mcollective']

$local_puppet_dir = windows_native_path("${::common_appdata}/Puppetlabs")
Expand Down Expand Up @@ -80,6 +82,12 @@
default => undef,
}

if ($master_agent_version != undef and versioncmp("${::clientversion}", '4.0.0') < 0) {
$package_version = $master_agent_version
} else {
$package_version = undef
}

$ssldir = "${confdir}/ssl"
$config = "${confdir}/puppet.conf"

Expand Down
Loading

0 comments on commit e7415ac

Please sign in to comment.