Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/master/pe 10914 add osx 109 upgrade #70

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
} else {
$_package_file_name = "${puppet_agent::package_name}-${puppet_agent::params::master_agent_version}-1.i386.pkg.gz"
}
} 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"
} else {
$_package_file_name = undef
}

class { '::puppet_agent::prepare':
Expand Down
7 changes: 7 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
source => "/opt/puppetlabs/packages/${_unzipped_package_name}",
require => Class['puppet_agent::install::remove_packages'],
}
} elsif $::operatingsystem == 'Darwin' and $::macosx_productversion_major =~ '10\.[9,10,11]' {
contain puppet_agent::install::remove_packages

$_package_options = {
source => "/opt/puppetlabs/packages/${package_file_name}",
require => Class['puppet_agent::install::remove_packages'],
}
} else {
$_package_options = {}
}
Expand Down
115 changes: 61 additions & 54 deletions manifests/install/remove_packages.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,70 @@

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

$package_options = $::operatingsystem ? {
'SLES' => {
uninstall_options => '--nodeps',
provider => 'rpm',
},
'Solaris' => {
adminfile => '/opt/puppetlabs/packages/solaris-noask',
},
default => {
if $::operatingsystem == 'Darwin' {

contain '::puppet_agent::install::remove_packages_osx'

} else {

$package_options = $::operatingsystem ? {
'SLES' => {
uninstall_options => '--nodeps',
provider => 'rpm',
},
'Solaris' => {
adminfile => '/opt/puppetlabs/packages/solaris-noask',
},
default => {
}
}
}

$packages = $::operatingsystem ? {
'Solaris' => [
'PUPpuppet',
'PUPaugeas',
'PUPdeep-merge',
'PUPfacter',
'PUPhiera',
'PUPlibyaml',
'PUPmcollective',
'PUPopenssl',
'PUPpuppet-enterprise-release',
'PUPruby',
'PUPruby-augeas',
'PUPruby-rgen',
'PUPruby-shadow',
'PUPstomp',
],
default => [
'pe-augeas',
'pe-mcollective-common',
'pe-rubygem-deep-merge',
'pe-mcollective',
'pe-puppet-enterprise-release',
'pe-libldap',
'pe-libyaml',
'pe-ruby-stomp',
'pe-ruby-augeas',
'pe-ruby-shadow',
'pe-hiera',
'pe-facter',
'pe-puppet',
'pe-openssl',
'pe-ruby',
'pe-ruby-rgen',
'pe-virt-what',
'pe-ruby-ldap',
]
}
$packages = $::operatingsystem ? {
'Solaris' => [
'PUPpuppet',
'PUPaugeas',
'PUPdeep-merge',
'PUPfacter',
'PUPhiera',
'PUPlibyaml',
'PUPmcollective',
'PUPopenssl',
'PUPpuppet-enterprise-release',
'PUPruby',
'PUPruby-augeas',
'PUPruby-rgen',
'PUPruby-shadow',
'PUPstomp',
],
default => [
'pe-augeas',
'pe-mcollective-common',
'pe-rubygem-deep-merge',
'pe-mcollective',
'pe-puppet-enterprise-release',
'pe-libldap',
'pe-libyaml',
'pe-ruby-stomp',
'pe-ruby-augeas',
'pe-ruby-shadow',
'pe-hiera',
'pe-facter',
'pe-puppet',
'pe-openssl',
'pe-ruby',
'pe-ruby-rgen',
'pe-virt-what',
'pe-ruby-ldap',
]
}

# We only need to remove these packages if we are transitioning from PE
# versions that are pre AIO.
$packages.each |$old_package| {
package { $old_package:
ensure => absent,
* => $package_options,
# We only need to remove these packages if we are transitioning from PE
# versions that are pre AIO.
$packages.each |$old_package| {
package { $old_package:
ensure => absent,
* => $package_options,
}
}
}
}
Expand Down
60 changes: 60 additions & 0 deletions manifests/install/remove_packages_osx.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# == Class puppet_agent::install::remove_packages_osx
#
# Sadly, special handling is required to clear up puppet_enterprise installation
# on 3.8.
#
class puppet_agent::install::remove_packages_osx {
assert_private()

if $::puppet_agent::is_pe {
# shutdown services
service { 'pe-puppet':
ensure => stopped,
}->
service { 'pe-mcollective':
ensure => stopped,
}->

# remove old users and groups
user { 'pe-puppet':
ensure => absent,
}->
user { 'pe-mcollective':
ensure => absent,
}->

# remove old /opt/puppet files
file { '/opt/puppet':
ensure => absent,
force => true,
backup => false,
}
# Can't delete /var/opt/lib/pe-puppet or we get errors because
# /var/opt/lib/pe-puppet/state is missing when puppet run tries to save
# report

# forget packages
[
'pe-augeas',
'pe-ruby-augeas',
'pe-openssl',
'pe-ruby',
'pe-cfpropertylist',
'pe-facter',
'pe-puppet',
'pe-mcollective',
'pe-hiera',
'pe-puppet-enterprise-release',
'pe-stomp',
'pe-libyaml',
'pe-ruby-rgen',
'pe-deep-merge',
'pe-ruby-shadow',
].each |$package| {
exec { "forget ${package}":
command => "/usr/sbin/pkgutil --forget com.puppetlabs.${package}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, the puppet osx package provider doesn't handle this? I'm disappointed. :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR's welcome. Unfortunately figuring out the signature of an installed package from a package name, without keeping state or running the installer, is a mystery to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should say I'm more disappointed in Apple for not writing a real package manager. It's definitely a hard problem to solve. Is there any way of getting a listing of all installed signatures so you could regex for package_name and uninstall if there is only one match?

require => File['/opt/puppet'],
}
}
}
}
14 changes: 14 additions & 0 deletions manifests/osfamily/darwin.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class puppet_agent::osfamily::darwin(
$package_file_name = undef,
) {
assert_private()

if $::macosx_productversion_major !~ '10\.[9,10,11]' {
fail("${::macosx_productname} ${::maxosx_productversion_major} not supported")
}

class { 'puppet_agent::prepare::package':
package_file_name => $package_file_name,
}
contain puppet_agent::prepare::package
}
4 changes: 2 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# == Class puppet_agent::params
#
# This class is meant to be called from puppet_agent.
# This class is meant to be called from puppet_agent
# It sets variables according to platform.
#
class puppet_agent::params {
Expand All @@ -22,7 +22,7 @@
}

case $::osfamily {
'RedHat', 'Amazon', 'Debian', 'Suse', 'Solaris': {
'RedHat', 'Amazon', 'Debian', 'Suse', 'Solaris', 'Darwin': {
$package_name = 'puppet-agent'
$service_names = ['puppet', 'mcollective']

Expand Down
2 changes: 1 addition & 1 deletion manifests/prepare.pp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# the osfamily of the client being configured.

case $::osfamily {
'redhat', 'debian', 'windows', 'solaris', 'aix', 'suse': {
'redhat', 'debian', 'windows', 'solaris', 'aix', 'suse', 'darwin': {
$_osfamily_class = downcase("::puppet_agent::osfamily::${::osfamily}")
class { $_osfamily_class:
package_file_name => $package_file_name
Expand Down
13 changes: 8 additions & 5 deletions manifests/prepare/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
file { ['/opt/puppetlabs', '/opt/puppetlabs/packages']:
ensure => directory,
}

file { "/opt/puppetlabs/packages/${package_file_name}":
ensure => present,
owner => 0,
group => 0,
mode => '0644',
source => $source,
ensure => present,
owner => 0,
group => 0,
mode => '0644',
source => $source,
backup => false,
require => File['/opt/puppetlabs/packages'],
}
}
}
78 changes: 78 additions & 0 deletions spec/classes/puppet_agent_osfamily_darwin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
require 'spec_helper'

describe 'puppet_agent', :unless => Puppet.version < "3.8.0" || Puppet.version >= "4.0.0" do
before(:each) do
# Need to mock the PE functions
Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args|
"4.0.0"
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args|
'1.2.5'
end
end

facts = {
:is_pe => true,
:osfamily => 'Darwin',
:operatingsystem => 'Darwin',
:macosx_productversion_major => '10.9',
:architecture => 'x86_64',
:servername => 'master.example.vm',
:clientcert => 'foo.example.vm',
}

describe 'unsupported environment' do
context "when OSX 10.8" do
let(:facts) do
facts.merge({
:platform_tag => "osx-10.8-x86_64",
:macosx_productversion_major => '10.8',
})
end

it { expect { catalogue }.to raise_error(/not supported/) }
end
end

describe 'supported environment' do
context "when OSX 10.9" do
let(:facts) do
facts.merge({
:is_pe => true,
:platform_tag => "osx-10.9-x86_64",
:macosx_productversion_major => '10.9',
})
end

it { should compile.with_all_deps }
it { is_expected.to contain_package('puppet-agent').with_source('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.osx10.9.dmg') }
end

context "when OSX 10.10" do
let(:facts) do
facts.merge({
:is_pe => true,
:platform_tag => "osx-10.10-x86_64",
:macosx_productversion_major => '10.10',
})
end

it { should compile.with_all_deps }
it { is_expected.to contain_package('puppet-agent').with_source('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.osx10.10.dmg') }
end

context "when OSX 10.11" do
let(:facts) do
facts.merge({
:is_pe => true,
:platform_tag => "osx-10.11-x86_64",
:macosx_productversion_major => '10.11',
})
end

it { should compile.with_all_deps }
it { is_expected.to contain_package('puppet-agent').with_source('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.osx10.11.dmg') }
end
end
end