10 changes: 8 additions & 2 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ fixtures:
forge_modules:
stdlib:
repo: "puppetlabs/stdlib"
ref: "5.1.0"
ref: "6.0.0"
inifile:
repo: "puppetlabs/inifile"
ref: "2.4.0"
apt:
repo: "puppetlabs/apt"
ref: "6.0.0"
ref: "7.0.1"
translate:
repo: "puppetlabs/translate"
ref: "1.2.0"
yumrepo_core:
repo: "puppetlabs/yumrepo_core"
facts:
repo: "puppetlabs/facts"
ref: "0.5.1"
symlinks:
puppet_agent: "#{source_dir}"
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require:
- rubocop-rspec
AllCops:
TargetRubyVersion: '2.1'
TargetRubyVersion: '2.3'
Include:
- "./**/*.rb"
Exclude:
Expand Down
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
sudo: false
git:
depth: 150
dist: trusty
language: ruby
cache: bundler
Expand All @@ -18,6 +20,8 @@ matrix:
include:
- rvm: 2.5.3
env: CHECK="validate lint spec"
- rvm: 2.5.3
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=spec
- rvm: 2.5.3
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=spec
- rvm: 2.3.8
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [2.2.0] - 2019-08-05

### Summary
Autodetect package_version for compiling master. Fedora 30 support. Upgrade to Beaker 4. Handle mcollective service restarts on agent upgrades.

### Features
- autodetect package_version based upon the compiling master ([MODULES-8923](https://tickets.puppetlabs.com/browse/MODULES-8923))
- Fedora 30 support
- Handle mcollective service restarts on agent upgrades ([MODULES-9173](https://tickets.puppetlabs.com/browse/MODULES-9173))
- Migrate puppet_agent module to Beaker 4 ([MODULES-9444](https://tickets.puppetlabs.com/browse/MODULES-9444))
- Support upgrade of RedHat Satellite puppet agent packages ([MODULES-7760](https://tickets.puppetlabs.com/browse/MODULES-7760))

### Bug fixes
- Missing puppetlabs-facts dependency for the install task([MODULES-8665](https://tickets.puppetlabs.com/browse/MODULES-8665))

## [2.1.2] - 2019-05-13

### Summary
Update for the URLs used to retrieve Puppet Agent. Fix for using the modules in a non PE Environment

### Bug fixes
- The Puppet Agent artifacts are now retrieved from *.puppet.com instead of *.puppetlabs.com ([RE-12326](https://tickets.puppetlabs.com/browse/RE-12326))
- set PC1 as the default Puppet Agent repository

## [2.1.1] - 2019-03-28

### Summary
Quick fix release for windows environment issue

### Bug fixes
- Update installation .ps1 script to force environment to production when executing "puppet config" ([MODULES-8821](https://tickets.puppetlabs.com/browse/MODULES-8821))

## [2.1.0] - 2019-03-26

Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @puppetlabs/night-s-watch
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", :require => false, :platforms => "ruby"
gem "puppet-module-win-system-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.37')
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4')
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || ["~> 1.0", ">= 1.0.1"])
gem "beaker-docker", '~> 0.3'
gem "beaker-vagrant", '~> 0.5'
gem "beaker-vmpooler", '~> 1.3'
Expand All @@ -66,7 +67,7 @@ group :system_tests do
gem "puppet-blacksmith", '~> 3.4', :require => false
# Bundler fails on 2.1.9 even though this group is excluded
if ENV['GEM_BOLT']
gem 'bolt', '~> 1.9', require: false
gem 'bolt', '~> 1.15', require: false
gem 'beaker-task_helper', '~> 1.5.2', require: false
end
end
Expand Down
20 changes: 12 additions & 8 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,21 @@

## Overview

A module for upgrading Puppet agents. Supports upgrading from Puppet 4 puppet-agent packages to later versions.
A module for upgrading Puppet agents. Supports upgrading from Puppet 4 puppet-agent packages to later versions including Puppet 4, Puppet 5, and Puppet 6.

Previous releases of this module, now unsupported, upgraded agents from later versions of Puppet 3 to Puppet 4.

## Module Description

The puppet_agent module installs the appropriate official Puppet package repository (on systems that support repositories); migrates configuration required by Puppet to new locations used by puppet-agent; and installs the puppet-agent package, removing the previous Puppet installation.

If a package_version parameter is provided, it will ensure that puppet-agent version is installed. The package_version parameter is required to perform upgrades starting from a puppet-agent package.
If a package_version parameter is provided, it will ensure that puppet-agent version is installed. The package_version parameter is required to perform upgrades starting from a puppet-agent package, also this parameter can be set to "auto", ensuring that agent version matches the version on the master without having to manually update package_version after upgrading the master(s).

## Setup

### What puppet_agent affects

* Puppet, Facter, Hiera, and MCollective (MCollective is no longer included in puppet6 installs).
* Puppet, Facter, Hiera, and MCollective (MCollective is no longer included in Puppet 6 installs).
* Puppet's SSL directory and puppet.conf.
* Removes deprecated settings from puppet.conf.

Expand Down Expand Up @@ -142,9 +144,7 @@ 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
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). **This parameter is required for installations not connected to Puppet Enterprise**
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 `puppet5` will pull in the most recent Puppet 5 release (for example: 5.5.10) as also will `puppet6` for Puppet 6 (for example: 6.3.0). **This parameter is required for installations not connected to Puppet Enterprise**
``` puppet
collection => 'puppet6'
```
Expand All @@ -171,6 +171,10 @@ The package version to upgrade to. This must be explicitly specified.
``` puppet
package_version => '5.5.10'
```
or
``` puppet
package_version => 'auto'
```

##### `service_names`

Expand Down Expand Up @@ -242,7 +246,7 @@ Base URL of the location of a mirror for Solaris packages. Currently, solaris pa

Base URL of the location of a mirror for AIX packages. Currently, AIX packages can only be made available by using puppetlabs-pe\_repo. This means the mirror must be of a PE master package serve.
``` puppet
solaris_source => 'https://my-pe_master-mirror.com'
aix_source => 'https://my-pe_master-mirror.com'
```


Expand Down Expand Up @@ -302,7 +306,7 @@ package `version` can be specified; if not, will install or upgrade to the lates

## Limitations

Mac OS X Open Source packages are currently not supported.
Mac OS X/macOS open source packages are not supported in puppet_agent module releases prior to v2.1.0.

### Known issues

Expand Down
6 changes: 3 additions & 3 deletions docker/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ LABEL before=${before}
# Install proper FROM repo: PC1 (puppet 4), puppet 5, or puppet 6.
RUN if [[ ${before} == 1.* ]]; then \
echo Installing PC1 repo; \
wget -O puppet-pc1.rpm http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm && \
wget -O puppet-pc1.rpm http://yum.puppet.com/puppetlabs-release-pc1-el-7.noarch.rpm && \
rpm -i puppet-pc1.rpm; \
elif [[ ${before} == 5.* ]]; then \
echo Installing PC1 repo; \
wget -O puppet5.rpm http://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm && \
wget -O puppet5.rpm http://yum.puppet.com/puppet5-release-el-7.noarch.rpm && \
rpm -i puppet5.rpm; \
elif [[ ${before} == 6.* ]]; then \
echo Installing PC1 repo; \
wget -O puppet6.rpm http://yum.puppetlabs.com/puppet6/puppet6-release-el-7.noarch.rpm && \
wget -O puppet6.rpm http://yum.puppet.com/puppet6-release-el-7.noarch.rpm && \
rpm -i puppet6.rpm; \
else echo no; \
fi
Expand Down
6 changes: 3 additions & 3 deletions docker/centos/Dockerfile.versions
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ RUN yum update -y \
&& yum clean all

# Install several repos: PC1 (puppet 4), puppet 5, and puppet 6.
RUN wget -O puppet-pc1.rpm http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm && \
RUN wget -O puppet-pc1.rpm http://yum.puppet.com/puppetlabs-release-pc1-el-7.noarch.rpm && \
rpm -i puppet-pc1.rpm --force --replacefiles && \
wget -O puppet5.rpm http://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm && \
wget -O puppet5.rpm http://yum.puppet.com/puppet5-release-el-7.noarch.rpm && \
rpm -i puppet5.rpm --force --replacefiles && \
wget -O puppet6.rpm http://yum.puppetlabs.com/puppet6/puppet6-release-el-7.noarch.rpm && \
wget -O puppet6.rpm http://yum.puppet.com/puppet6-release-el-7.noarch.rpm && \
rpm -i puppet6.rpm --force --replacefiles --nodeps

# Print out available package versions for puppet-agent. If a specific version
Expand Down
13 changes: 10 additions & 3 deletions files/install_puppet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,15 @@ function Script:Lock-Installation {
begin {
Write-Log "Locking installation"
if (Test-Path $install_pid_lock) {
Write-Log "Another process has control of $install_pid_lock! Cannot lock, exiting..."
throw
# if the PID found in $install_pid_lock file is not running, this means
# the installation can take control of the file, and assign the new running PID
if((Get-Process -Id (Get-Content $install_pid_lock) -ErrorAction SilentlyContinue) -eq $null){
Write-Log "Process with PID found in $install_pid_lock is no longer running! Continuing installation and assigning new PID!"
$PID | Out-File -FilePath $install_pid_lock
}else{
Write-Log "Another process has control of $install_pid_lock! Cannot lock, exiting..."
throw
}
} else {
$PID | Out-File -NoClobber -FilePath $install_pid_lock
}
Expand Down Expand Up @@ -256,7 +263,7 @@ $service_names=@(
"mcollective"
)
try {
$state_dir = (puppet.bat config print statedir)
$state_dir = (puppet.bat config print statedir --environment production)
Write-Log "Installation PID:$PID"
$install_pid_lock = Join-Path -Path $state_dir -ChildPath 'puppet_agent_upgrade.pid'
Lock-Installation $install_pid_lock
Expand Down
40 changes: 28 additions & 12 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# [package_name]
# The package to upgrade to, i.e. `puppet-agent`.
# [package_version]
# The package version to upgrade to. Explicitly specify a version to upgrade
# The package version to upgrade to. Explicitly specify the version to upgrade to,
# or set to 'auto' to specify the version of the compiling master.
# [service_names]
# An array of services to start, normally `puppet` and `mcollective`.
# None will be started if the array is empty.
Expand Down Expand Up @@ -131,30 +132,45 @@
# In this code-path, $package_version != undef AND we are not on a PE infrastructure
# node since $::pe_server_version is not defined

if $package_version !~ /^\d+\.\d+\.\d+([.-]?\d*|\.\d+\.g[0-9a-f]+)$/ {
fail("invalid version ${package_version} requested")
if $::architecture == 'x86' and $arch == 'x64' {
fail('Unable to install x64 on a x86 system')
}

# Strip git sha from dev builds
if $package_version =~ /g/ {
$_expected_package_version = split($package_version, /[.-]g.*/)[0]
if $package_version == 'auto' {
$master_or_package_version = $::serverversion
} else {
$_expected_package_version = $package_version
$master_or_package_version = $package_version
}

$aio_upgrade_required = versioncmp("${::aio_agent_version}", "${_expected_package_version}") < 0
if $::osfamily == 'redhat' {
if $master_or_package_version !~ /^\d+\.\d+\.\d+.*$/ {
fail("invalid version ${master_or_package_version} requested")
}
}
else {
if $master_or_package_version !~ /^\d+\.\d+\.\d+([.-]?\d*|\.\d+\.g[0-9a-f]+)$/ {
fail("invalid version ${master_or_package_version} requested")
}
}

if $::architecture == 'x86' and $arch == 'x64' {
fail('Unable to install x64 on a x86 system')
# Strip git sha from dev builds
if $master_or_package_version =~ /.g/ {
$_expected_package_version = split($master_or_package_version, /[.-]g.*/)[0]
} elsif $::osfamily == 'redhat' {
$_expected_package_version = $master_or_package_version.match(/^\d+\.\d+\.\d+/)[0]
} else {
$_expected_package_version = $master_or_package_version
}

$aio_upgrade_required = versioncmp("${::aio_agent_version}", "${_expected_package_version}") < 0

if $::operatingsystem == 'Solaris' and $::operatingsystemmajrelease == '11' {
# Strip letters from development builds. Unique to Solaris 11 packaging.
$_version_without_letters = regsubst($::puppet_agent::package_version, '[a-zA-Z]', '', 'G')
$_version_without_letters = regsubst($master_or_package_version, '[a-zA-Z]', '', 'G')
$_version_without_orphan_dashes = regsubst($_version_without_letters, '(^-|-$)', '', 'G')
$_package_version = regsubst($_version_without_orphan_dashes, '\b(?:0*?)([1-9]\d*|0)\b', '\1', 'G')
} else {
$_package_version = $package_version
$_package_version = $master_or_package_version
}

class { '::puppet_agent::prepare':
Expand Down
10 changes: 10 additions & 0 deletions manifests/install/windows.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
-PuppetStartType '${_agent_startup_mode}' \
-InstallArgs '${_install_options}' \
${_move_dll_workaround}",
unless => "${::system32}\\WindowsPowerShell\\v1.0\\powershell.exe \
-ExecutionPolicy Bypass \
-NoProfile \
-NoLogo \
-NonInteractive \
-Command {\$CurrentVersion = [string](facter.bat -p aio_agent_version); \
if (\$CurrentVersion -eq '${puppet_agent::_expected_package_version}') { \
exit 0; \
} \
exit 1; }.Invoke()",
path => $::path,
require => [
Puppet_agent_upgrade_error['puppet_agent_upgrade_failure.log'],
Expand Down
7 changes: 4 additions & 3 deletions manifests/osfamily/aix.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@
$aix_ver_number = '6.1'
}
}

if $::puppet_agent::absolute_source {
$source = $::puppet_agent::absolute_source
} elsif $::puppet_agent::alternate_pe_source {
$source = "${::puppet_agent::alternate_pe_source}/packages/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::package_version}-1.aix${aix_ver_number}.ppc.rpm"
$source = "${::puppet_agent::alternate_pe_source}/packages/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
} elsif $::puppet_agent::source {
$source = "${::puppet_agent::source}/packages/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::package_version}-1.aix${aix_ver_number}.ppc.rpm"
$source = "${::puppet_agent::source}/packages/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
} else {
$source = "${::puppet_agent::aix_source}/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::package_version}-1.aix${aix_ver_number}.ppc.rpm"
$source = "${::puppet_agent::aix_source}/${pe_server_version}/aix-${aix_ver_number}-power/${::puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.aix${aix_ver_number}.ppc.rpm"
}

class { '::puppet_agent::prepare::package':
Expand Down
9 changes: 5 additions & 4 deletions manifests/osfamily/darwin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
} elsif ($::puppet_agent::is_pe and (!$::puppet_agent::use_alternate_sources)) {
$pe_server_version = pe_build_version()
if $::puppet_agent::alternate_pe_source {
$source = "${::puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${puppet_agent::package_version}-1.osx${$::macosx_productversion_major}.dmg"
$source = "${::puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.osx${$::macosx_productversion_major}.dmg"
} elsif $::puppet_agent::source {
$source = "${::puppet_agent::source}/packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${puppet_agent::package_version}-1.osx${$::macosx_productversion_major}.dmg"
$source = "${::puppet_agent::source}/packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.osx${$::macosx_productversion_major}.dmg"
} else {
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${puppet_agent::package_version}-1.osx${$::macosx_productversion_major}.dmg"
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.osx${$::macosx_productversion_major}.dmg"
}
} else {
$source = "${::puppet_agent::mac_source}/mac/${::puppet_agent::collection}/${::macosx_productversion_major}/${::puppet_agent::arch}/${puppet_agent::package_name}-${puppet_agent::package_version}-1.osx${$::macosx_productversion_major}.dmg"
$source = "${::puppet_agent::mac_source}/mac/${::puppet_agent::collection}/${::macosx_productversion_major}/${::puppet_agent::arch}/${puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.osx${$::macosx_productversion_major}.dmg"
}

class { '::puppet_agent::prepare::package':
source => $source,
}
Expand Down
6 changes: 5 additions & 1 deletion manifests/osfamily/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
$source = "https://${::puppet_master_server}:8140/packages/${pe_server_version}/${pe_repo_dir}"
}
} else {
$source = "${::puppet_agent::yum_source}/${::puppet_agent::collection}/${platform_and_version}/${::puppet_agent::arch}"
if $::puppet_agent::collection == 'PC1' {
$source = "${::puppet_agent::yum_source}/${platform_and_version}/${::puppet_agent::collection}/${::puppet_agent::arch}"
} else {
$source = "${::puppet_agent::yum_source}/${::puppet_agent::collection}/${platform_and_version}/${::puppet_agent::arch}"
}
}


Expand Down
Loading