Skip to content

Commit

Permalink
Merge pull request #373 from McdonaldSeanp/MODULES8319
Browse files Browse the repository at this point in the history
(MODULES-8319) Update service to exclude MCO for puppet > 6
  • Loading branch information
speedofdark authored Jan 28, 2019
2 parents 89e8355 + 59a7179 commit 9e1c23a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
8 changes: 4 additions & 4 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ The architecture version you wish to install. Defaults to `$::facts['architectur

##### `collection`

The Puppet Collection to track, should be one of `puppet5` or `puppet6`. Puppet collections contain the latest agents included
The Puppet Collection to track, should be one of `puppet5` or `puppet6`. Puppet collections contain the latest agents included
in the collection's series, so the latest 5 series in puppet5 (for example: 5.5.10) and the latest 6 series in puppet6 (for
example: 6.1.0).
example: 6.1.0). **This parameter is required for installations not connected to PE**
``` puppet
collection => 'puppet6'
```
Expand All @@ -147,8 +147,8 @@ and the native package providers will be used to query pre-configured repos on t
##### `package_version`

The package version to upgrade to. Defaults to the puppet master's latest supported version if compiled with A PE master,
otherwise `undef` (meaning get the latest Open Source release). Explicitly specify a version to upgrade from puppet-agent
packages (implying Puppet >= 4.0).
otherwise `undef` (meaning get the latest Open Source release). Explicitly specify a version to upgrade from puppet-agent
packages (implying Puppet >= 4.0). **This parameter is required for installations not connected to PE**
``` puppet
package_version => '5.5.8'
```
Expand Down
60 changes: 34 additions & 26 deletions acceptance/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,35 @@ def with_default_site_pp(site_pp_contents, master_opts = {})
# PMT will have installed dependencies in the production environment; We will put our manifest there, too:
site_pp_path = File.join(puppet_config(master, 'codedir'), 'environments', 'production', 'manifests', 'site.pp')

if file_exists_on(master, site_pp_path)
original_contents = file_contents_on(master, site_pp_path)
original_perms = on(master, %(stat -c "%a" #{site_pp_path})).stdout.strip

teardown do
on(master, %(echo "#{original_contents}" > #{site_pp_path}))
on(master, %(chmod #{original_perms} #{site_pp_path}))
end
else
teardown do
on(master, "rm -f #{site_pp_path}")
step "Save current site.pp" do
if file_exists_on(master, site_pp_path)
original_contents = file_contents_on(master, site_pp_path)
original_perms = on(master, %(stat -c "%a" #{site_pp_path})).stdout.strip

teardown do
step "restore original manifest" do
on(master, %(echo "#{original_contents}" > #{site_pp_path}))
on(master, %(chmod #{original_perms} #{site_pp_path}))
end
end
else
teardown do
on(master, "rm -f #{site_pp_path}")
end
end
end

create_remote_file(master, site_pp_path, manifest_contents)
on(master, %(chown #{puppet_user(master)} "#{site_pp_path}"))
on(master, %(chmod 755 "#{site_pp_path}"))
step "create site.pp on master with manifest:\n#{manifest_contents}" do
create_remote_file(master, site_pp_path, manifest_contents)
on(master, %(chown #{puppet_user(master)} "#{site_pp_path}"))
on(master, %(chmod 755 "#{site_pp_path}"))
end

with_puppet_running_on(master, master_opts) do
on(agents_only, puppet(%(agent --test --server #{master.hostname})), acceptable_exit_codes: [0, 2])
yield if block_given?
step "Execute puppet runs" do
with_puppet_running_on(master, master_opts) do
on(agents_only, puppet(%(agent --test --server #{master.hostname})), acceptable_exit_codes: [0, 2])
yield if block_given?
end
end
end

Expand All @@ -215,16 +223,16 @@ def with_default_site_pp(site_pp_contents, master_opts = {})
# @param [String] upgrade_manifest A manifest to apply to all agent nodes
def run_foss_upgrade_with_manifest(initial_package_version_or_collection, upgrade_manifest)
confine :except, platform: PE_ONLY_UPGRADES

logger.notify("Performing FOSS upgrade with default manifest:\n#{upgrade_manifest}")

prepare_upgrade_with(initial_package_version_or_collection)
teardown { purge_agents }

with_default_site_pp(upgrade_manifest) do
# Put your assertions here
yield if block_given?
step "Prepare for FOSS upgrade" do
prepare_upgrade_with(initial_package_version_or_collection)
end
step "Execute FOSS upgrade with default manifest:\n#{upgrade_manifest}" do
with_default_site_pp(upgrade_manifest) do
# Put your assertions here
yield if block_given?
end
end
teardown { purge_agents }
end
end
end
Expand Down
11 changes: 9 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@
class puppet_agent::service {
assert_private()

# Starting with puppet6 collections we no longer carry the mcollective service
if $::puppet_agent::collection != 'PC1' and $::puppet_agent::collection != 'puppet5' {
$_service_names = delete($::puppet_agent::service_names, 'mcollective')
} else {
$_service_names = $::puppet_agent::service_names
}

if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '10' and versioncmp("${::clientversion}", '5.0.0') < 0 {
# Skip managing service, upgrade script will handle it.
} elsif $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' and
((versioncmp("${::clientversion}", '4.0.0') < 0) or $puppet_agent::aio_upgrade_required) {
# Only use script if we just performed an upgrade.
$_logfile = "${::env_temp_variable}/solaris_start_puppet.log"
# We'll need to pass the names of the services to start to the script
$_service_names_arg = join($::puppet_agent::service_names, ' ')
$_service_names_arg = join($_service_names, ' ')
notice ("Puppet service start log file at ${_logfile}")
file { "${::env_temp_variable}/solaris_start_puppet.sh":
ensure => file,
Expand All @@ -28,7 +35,7 @@
ensure => directory,
}
} else {
$::puppet_agent::service_names.each |$service| {
$_service_names.each |$service| {
service { $service:
ensure => running,
enable => true,
Expand Down

0 comments on commit 9e1c23a

Please sign in to comment.