Skip to content

Commit

Permalink
(PE-12299) Add Solaris 11 support
Browse files Browse the repository at this point in the history
This commit plumbs the puppet agent module to add Solaris 11 support.

This commit should be fairly consistent with how pe_repo handles
upgrading agents on Solaris 11 by updating the repo in
`/etc/puppetlabs/installer/solaris.repo` with the new puppet-agent
package and installing puppet-agent from there

Lots of things in this commit are less than ideal but the current state
of how Solaris 11 packaging handles files through
uninstallation/installation.

Since Solaris 11 will not uninstall packages if dependant packages are
also installed so the packages must be removed in a specific order or
else the puppet run will fail.

When uninstalling the pe-* packages, Solaris 11 decides to completely
remove everything in `/etc/puppetlabs/` which is why this commit has to
go through and copy it to a temporary location during the upgrade.
However to install puppet-agent, the package needs to be in the repo
that lives in `/etc/puppetlabs/installer/solaris.repo` so the that repo
needs to be put back into place. After installing the puppet-agent
package it overwrites the existing configuration files with the default
configuration files. After installing the puppet-agent module the
/etc/puppetlabs directory is again copied into place so that the user
doesn't lose the ability to talk to the master server or any other
configurations that live in /etc/puppetlabs.

When upgrading Solaris 11 agents, the services are in a maintenance
state where Puppet is unable to start them. Use a script that waits for
the currently running agent run to stop and then calls puppet to ensure
that puppet and mcollective are running so that users do not have to
login to the nodes to perform these steps by hand.

This behavior is currently what windows is doing to start puppet and
mcollective agents when upgrading with the puppet_agent module.
  • Loading branch information
Britt Gresham authored and Michael Smith committed Mar 18, 2016
1 parent b9df9aa commit c5932ba
Show file tree
Hide file tree
Showing 12 changed files with 349 additions and 36 deletions.
20 changes: 17 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@

if $::operatingsystem == 'SLES' and $::operatingsystemmajrelease == '10' {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.sles10.${::architecture}.rpm"
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' {
} elsif $::operatingsystem == 'Solaris' {
if $arch =~ /^sun4[uv]$/ {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.sparc.pkg.gz"
if $::operatingsystemmajrelease == '10' {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.sparc.pkg.gz"
} elsif $::operatingsystemmajrelease == '11' {
# Strip letters from development builds.
$_version_without_letters = regsubst($puppet_agent::params::master_agent_version, /[a-zA-Z]/, '', 'G')
$_solaris_version = regsubst($_version_without_letters, /(^-|-$)/, '', 'G')
$_package_file_name = "${puppet_agent::package_name}@${_solaris_version},5.11-1.sparc.p5p"
}
} else {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.i386.pkg.gz"
if $::operatingsystemmajrelease == '10' {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.i386.pkg.gz"
} elsif $::operatingsystemmajrelease == '11' {
# Strip letters from development builds.
$_version_without_letters = regsubst($puppet_agent::params::master_agent_version, /[a-zA-Z]/, '', 'G')
$_solaris_version = regsubst($_version_without_letters, /(^-|-$)/, '', 'G')
$_package_file_name = "${puppet_agent::package_name}@${_solaris_version},5.11-1.i386.p5p"
}
}
} elsif $::operatingsystem == 'Darwin' and $::macosx_productversion_major =~ /10\.[9,10,11]/ {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.osx${$::macosx_productversion_major}.dmg"
Expand Down
19 changes: 19 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@
source => "/opt/puppetlabs/packages/${_unzipped_package_name}",
require => Class['puppet_agent::install::remove_packages'],
}
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' {
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 Down
88 changes: 76 additions & 12 deletions manifests/install/remove_packages.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@

} else {

$package_options = $::operatingsystem ? {
'SLES' => {
if $::operatingsystem == 'SLES' {
$package_options = {
uninstall_options => '--nodeps',
provider => 'rpm',
},
'AIX' => {
}
} elsif $::operatingsystem == 'AIX' {
$package_options = {
uninstall_options => '--nodeps',
provider => 'rpm',
},
'Solaris' => {
}
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' {
$package_options = {
adminfile => '/opt/puppetlabs/packages/solaris-noask',
},
default => {
}
} else {
$package_options = {}
}

$packages = $::operatingsystem ? {
'Solaris' => [
if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' {
$packages = [
'PUPpuppet',
'PUPaugeas',
'PUPdeep-merge',
Expand All @@ -47,8 +49,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
63 changes: 63 additions & 0 deletions manifests/osfamily/solaris.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,69 @@
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'

# 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',
path => '/bin:/usr/bin:/sbin:/usr/sbin',
logoutput => 'on_failure',
notify => Exec['puppet_agent remove existing repo'],
}

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',
notify => Exec['puppet_agent create repo'],
}

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',
notify => Exec['puppet_agent set publisher'],
refreshonly => true,
}

exec { 'puppet_agent set publisher':
command => "pkgrepo set -s ${pkgrepo_dir} publisher/prefix=puppetlabs.com",
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',
require => Exec['puppet_agent set publisher'],
logoutput => 'on_failure',
}

# 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
4 changes: 3 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
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 Down
3 changes: 2 additions & 1 deletion manifests/prepare.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
'redhat', 'debian', 'windows', 'solaris', 'aix', 'suse', 'darwin': {
$_osfamily_class = downcase("::puppet_agent::osfamily::${::osfamily}")
class { $_osfamily_class:
package_file_name => $package_file_name
package_file_name => $package_file_name,
require => Class['puppet_agent::prepare::puppet_config'],
}
contain $_osfamily_class
}
Expand Down
28 changes: 18 additions & 10 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,25 @@
class puppet_agent::service {
assert_private()

$::puppet_agent::service_names.each |$service| {
service { $service:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}

if $::operatingsystem == 'Solaris' {
if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' {
contain '::puppet_agent::service::solaris'
Service[$::puppet_agent::service_names] -> Class['::puppet_agent::service::solaris']
} else {

$::puppet_agent::service_names.each |$service| {
service { $service:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}

if $::operatingsystem == 'Solaris' {
contain '::puppet_agent::service::solaris'
Service[$::puppet_agent::service_names] -> Class['::puppet_agent::service::solaris']
}

}

}
13 changes: 13 additions & 0 deletions manifests/service/solaris.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,18 @@
service { 'pe-puppet':
ensure => stopped,
}
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' {
file { '/tmp/solaris_start_puppet.sh':
ensure => file,
content => template('puppet_agent/solaris_start_puppet.sh.erb'),
mode => '0755',
} ->
exec { 'solaris_start_puppet.sh':
command => '/tmp/solaris_start_puppet.sh &',
path => '/usr/bin:/bin:/usr/sbin',
}
file { ['/var/opt/lib', '/var/opt/lib/pe-puppet', '/var/opt/lib/pe-puppet/state']:
ensure => directory,
}
}
}
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"10"
"10",
"11"
]
},
{
Expand Down
Loading

0 comments on commit c5932ba

Please sign in to comment.