14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ script: bundle exec rake test
matrix:
include:
- rvm: 1.8.7
env: PUPPET_VERSION="~> 3.7.5"
env: PUPPET_GEM_VERSION="~> 3.7.5"
- rvm: 1.8.7
env: PUPPET_VERSION="~> 3.8.1"
env: PUPPET_GEM_VERSION="~> 3.8.1"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.8.1"
env: PUPPET_GEM_VERSION="~> 3.8.1"
- rvm: 2.0.0
env: PUPPET_VERSION="~> 3.8.1"
- rvm: 2.1.6
env: PUPPET_VERSION="~> 4.0.0"
env: PUPPET_GEM_VERSION="~> 3.8.1"
- rvm: 2.1.9
env: PUPPET_GEM_VERSION="~> 4.0.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 4.8.0"
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.3.1] - 2016-11-17

### Summary
This is a bug-fix release

### Known issues
Carried-over from prior releases:
- For Windows, trigger an agent run after upgrade to get Puppet to create the necessary directory structures.
- Upgrades on EL4-based systems are not supported.
- Mac OS X Open Source package upgrades are not yet implemented.

### Bug fixes
- Fix upgrading a global Solaris zone would break upgrading other zones ([MODULES-4092](https://tickets.puppetlabs.com/browse/MODULES-4092))
- Fix line endings of `install_puppet.bat`
- Fix upgrading between releases of the same package version ([MODULES-4030](https://tickets.puppetlabs.com/browse/MODULES-4030))

## [1.3.0] - 2016-10-19

### Summary
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ By default the tests use a baseline version of Puppet.
If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:

export PUPPET_VERSION="~> 3.2.0"
export PUPPET_GEM_VERSION="~> 3.2.0"

Install the dependencies like so...

Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
group :development, :test do
gem 'rake', '~> 10.4'
gem 'puppet', ENV['PUPPET_VERSION'] || '~> 3.8'
gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 4'
gem 'rspec', '< 3.2.0' # https://github.com/rspec/rspec-core/issues/1864
gem 'rspec-puppet', '~> 2.2'
gem 'puppetlabs_spec_helper', '~> 0.10'
gem 'json_pure', '~> 1.8.3' # avoid version incompatible with Puppet 3.8
gem 'json', '~> 1.8.3' # avoid trying to pull a newer version with Ruby 1.8.7
gem 'metadata-json-lint', '~> 0.0'
gem 'rspec-puppet-facts', '~> 1.3'
gem 'semantic_puppet', '0.1.3'
gem 'puppet-blacksmith', '>= 3.4.0', :require => false, :platforms => 'ruby' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9.3')
end

group :system_tests do
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"version": 1,
"file_format": "This MAINTAINERS file format is described at http://pup.pt/maintainers",
"issues": "https://github.com/puppetlabs/puppetlabs-puppet_agent/issues",
"internal_list": "https://groups.google.com/a/puppet.com/forum/?hl=en#!forum/discuss-puppetlabs-puppet_agent-maintainers",
"people": [
{
"github": "MikaelSmith",
Expand Down
7 changes: 4 additions & 3 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@

$_unzipped_package_name = regsubst($package_file_name, '\.gz$', '')
$_package_options = {
adminfile => '/opt/puppetlabs/packages/solaris-noask',
source => "/opt/puppetlabs/packages/${_unzipped_package_name}",
require => Class['puppet_agent::install::remove_packages'],
adminfile => '/opt/puppetlabs/packages/solaris-noask',
source => "/opt/puppetlabs/packages/${_unzipped_package_name}",
require => Class['puppet_agent::install::remove_packages'],
install_options => '-G',
}
} 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.
Expand Down
28 changes: 19 additions & 9 deletions manifests/prepare/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
) {
assert_private()

# Guard this so that we do not perform expensive checksum logic on the master
# for the large puppet-agent file if we have already upgraded.
if $puppet_agent::params::master_agent_version != $::aio_agent_version {
# As it is currently written, this will only work if the `pe_build_version()` function
# is available.
if $puppet_agent::is_pe {
$pe_server_version = pe_build_version()

if $::osfamily == 'windows' {
Expand All @@ -39,13 +39,23 @@
$mode = '0644'
}

# When running against a puppet 3 agent, we want to use the
# default checksum method, due to old bugs when specifying custom
# checksums. For puppet 4, we can use sha256lite and avoid some
# extra processing time.
$checksum = $::aio_agent_version ? {
undef => undef,
default => sha256lite,
}

file { $local_package_file_path:
ensure => present,
owner => $::puppet_agent::params::user,
group => $::puppet_agent::params::group,
mode => $mode,
source => $source,
require => File[$::puppet_agent::params::local_packages_dir],
ensure => present,
owner => $::puppet_agent::params::user,
group => $::puppet_agent::params::group,
mode => $mode,
source => $source,
require => File[$::puppet_agent::params::local_packages_dir],
checksum => $checksum
}
}
}
2 changes: 1 addition & 1 deletion manifests/prepare/puppet_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}

# When upgrading to 1.4.x or later remove pluginsync
if (($package_version == undef and $old_packages) or (versioncmp($package_version, '1.4.0') >= 0))
if (($package_version == undef and $old_packages) or (versioncmp("${package_version}", '1.4.0') >= 0))
and !defined(Ini_setting["${section}/pluginsync"]) {
$removed_settings = $_removed_settings + ['pluginsync']
} else {
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-puppet_agent",
"version": "1.3.0",
"version": "1.3.1",
"author": "puppetlabs",
"summary": "Upgrades Puppet 3.7+ and All-In-One Puppet Agents",
"license": "Apache-2.0",
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/puppet_agent_osfamily_solaris_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
is_expected.to contain_package('puppet-agent').with_adminfile('/opt/puppetlabs/packages/solaris-noask')
is_expected.to contain_package('puppet-agent').with_ensure('present')
is_expected.to contain_package('puppet-agent').with_source("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg")
is_expected.to contain_package('puppet-agent').with_install_options('-G')
end
end

Expand Down Expand Up @@ -449,6 +450,7 @@
is_expected.to contain_package('puppet-agent').with_adminfile('/opt/puppetlabs/packages/solaris-noask')
is_expected.to contain_package('puppet-agent').with_ensure('present')
is_expected.to contain_package('puppet-agent').with_source("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.sparc.pkg")
is_expected.to contain_package('puppet-agent').with_install_options('-G')
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def global_facts(facts, os)
it { is_expected.to contain_class('puppet_agent') }
it { is_expected.to contain_class('puppet_agent::params') }
it { is_expected.to contain_class('puppet_agent::prepare') }
it { is_expected.to contain_class('puppet_agent::install').that_requires('puppet_agent::prepare') }
it { is_expected.to contain_class('puppet_agent::install').that_requires('Class[puppet_agent::prepare]') }

if facts[:osfamily] == 'RedHat'
if facts[:operatingsystem] == 'Fedora'
Expand Down
98 changes: 49 additions & 49 deletions templates/install_puppet.bat.erb
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
SET

set AGENT_PID=%1
set windowTitle=Puppet Agent Upgrade
title %windowTitle%

set pid=
for /f "tokens=2" %%a in ('tasklist /v ^| findstr /c:"%windowTitle%"') do set pid=%%a
set pid_path=%~dp0puppet_agent_upgrade.pid

set environment=
for /f "delims=" %%i in ('puppet config print --section agent environment') do set environment=%%i

if exist %pid_path% del %pid_path%
@echo %pid%> %pid_path%

SET /A pid_checks_performed=0

:wait_for_pid
REM Wait 5 seconds
ping 127.0.0.1 -n 6 > NUL
wmic path Win32_Process where handle=%AGENT_PID% get handle /format:textvaluelist | findstr /I "Handle=%AGENT_PID%"

SET /A pid_checks_performed+=1
REM Wait for a max of 120 seconds (or 24 iterations) before aborting the upgrade
IF %errorlevel% == 0 IF %pid_checks_performed% == 24 (
REM Adding CustomSource allows EventCreate to work properly
reg add HKLM\SYSTEM\CurrentControlSet\services\eventlog\Application\Puppet /v CustomSource /t REG_DWORD /d 1 /f
EVENTCREATE /T ERROR /L APPLICATION /SO Puppet /ID 101 /D "Puppet agent upgrade failed while waiting for Puppet process [ID: %AGENT_PID%] to exit."
GOTO End
)

IF %errorlevel% == 0 ( GOTO wait_for_pid )

REM This *must* occur after Puppet Agent has finished applying its
REM prior catalog which manages the pxp-agent service state. If not,
REM the catalog includes the PE module which starts the service and
REM sets its startup type, which prevents installs from proceeding.
REM This may fail on agents without pxp-agent, but since this is not
REM run interactively and the next command sets ERRORLEVEL, it's OK.
net stop pxp-agent

start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*vx "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>" PUPPET_AGENT_ENVIRONMENT="%environment%" <% unless @install_dir.to_s.empty? -%>INSTALLDIR="<%= @install_dir %>"<% end -%>

:End

if exist %pid_path% del %pid_path%

ENDLOCAL
SET

set AGENT_PID=%1
set windowTitle=Puppet Agent Upgrade
title %windowTitle%

set pid=
for /f "tokens=2" %%a in ('tasklist /v ^| findstr /c:"%windowTitle%"') do set pid=%%a
set pid_path=%~dp0puppet_agent_upgrade.pid

set environment=
for /f "delims=" %%i in ('puppet config print --section agent environment') do set environment=%%i

if exist %pid_path% del %pid_path%
@echo %pid%> %pid_path%

SET /A pid_checks_performed=0

:wait_for_pid
REM Wait 5 seconds
ping 127.0.0.1 -n 6 > NUL
wmic path Win32_Process where handle=%AGENT_PID% get handle /format:textvaluelist | findstr /I "Handle=%AGENT_PID%"

SET /A pid_checks_performed+=1
REM Wait for a max of 120 seconds (or 24 iterations) before aborting the upgrade
IF %errorlevel% == 0 IF %pid_checks_performed% == 24 (
REM Adding CustomSource allows EventCreate to work properly
reg add HKLM\SYSTEM\CurrentControlSet\services\eventlog\Application\Puppet /v CustomSource /t REG_DWORD /d 1 /f
EVENTCREATE /T ERROR /L APPLICATION /SO Puppet /ID 101 /D "Puppet agent upgrade failed while waiting for Puppet process [ID: %AGENT_PID%] to exit."
GOTO End
)

IF %errorlevel% == 0 ( GOTO wait_for_pid )

REM This *must* occur after Puppet Agent has finished applying its
REM prior catalog which manages the pxp-agent service state. If not,
REM the catalog includes the PE module which starts the service and
REM sets its startup type, which prevents installs from proceeding.
REM This may fail on agents without pxp-agent, but since this is not
REM run interactively and the next command sets ERRORLEVEL, it's OK.
net stop pxp-agent

start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*vx "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>" PUPPET_AGENT_ENVIRONMENT="%environment%" <% unless @install_dir.to_s.empty? -%>INSTALLDIR="<%= @install_dir %>"<% end -%>

:End

if exist %pid_path% del %pid_path%

ENDLOCAL