13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0] - 2015-07-28

### Summary

Fixed minor bugs and improved documentation. Now a Puppet Supported module.

### Features
- Improved documentation of upgrade process.

### Bugfixes
- For Windows PE upgrades, by default install the agent version corresponding to the PE master.
- Reset puppet.conf's classfile setting.

## [0.2.0] - 2015-07-21

### Summary
Expand Down
23 changes: 16 additions & 7 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ The puppet_agent module installs the Puppet Collection 1 repo (on systems that s

* Puppet, Facter, Hiera, and MCollective.
* Puppet's SSL directory and puppet.conf.
* MCollective's server.cfg.
* MCollective's server.cfg and client.cfg.
* Removes deprecated settings from puppet.conf.
* Updates puppet.conf and server.cfg for behavioral changes in puppet-agent (future parser is the now the default, and MCollective has a new varlog location).
* Updates puppet.conf and server.cfg for behavioral changes in puppet-agent (future parser is now the default, and MCollective has a new varlog location).

### Setup Requirements

You must be running Puppet 3.8 with `stringify_facts` set to 'false'. Agents should already be pointed at a master running Puppet Server 2.1 or greater, and thus successfully applying catalogs compiled with the Puppet 4 language.
Your agents must be running Puppet 3.8 with `stringify_facts` set to 'false'. Agents should already be pointed at a master running Puppet Server 2.1 or greater, and thus successfully applying catalogs compiled with the Puppet 4 language.

### Beginning with puppet_agent

Expand All @@ -51,13 +51,22 @@ Add the class to agents you want to upgrade:
include ::puppet_agent
~~~

This installs the latest released version of Puppet from Puppet Collection 1.

To upgrade with this module, first stand up a Puppet Server 2.1 master---which supports backward compatibility with Puppet 3 agents---and point the agent you want to upgrade at that master. Once you've confirmed the agent runs successfully against the new master, and thus the Puppet 4 language, apply the class to the agent and confirm that it checks back in after a successful upgrade. Further details on upgrading are available [here](http://docs.puppetlabs.com/puppet/4.2/reference/upgrade_major_pre.html).

As part of preparing the agent for Puppet 4, the module performs several significant steps:
* Copies SSL files (based on their location settings: ssldir, certdir, privatedir, privatekeydir, publickeydir, requestdir) to new Puppet 4 defaults, and restore those settings to default in puppet.conf.
* Resets non-deprecated settings to defaults: disable_warnings, vardir, rundir, libdir, confdir, ssldir, and classfile.
* Resets logfile in MCollective's server.cfg and client.cfg.
* Adds new libdir and plugin.yaml locations to MCollective's server.cfg and client.cfg.

##Reference

###Public classes
* [`puppet_agent`](#class-puppetagent)

###Private classes
* `puppet_agent::config` : Configures the services.
* `puppet_agent::install`: Installs packages.
* `puppet_agent::prepare`: Prepares the agent for upgrade.
* `puppet_agent::service`: Ensures the services are running.
Expand Down Expand Up @@ -99,9 +108,9 @@ This module supports:
In addition, there are several known issues with Windows:

* To upgrade the agent by executing `puppet agent -t` interactively in a console, you must close the console and wait for the upgrade to finish before attempting to use the `puppet` command again.
* MSI installation failures do not produce any error. If the install fails, puppet_agent continues to be applied to the agent.
If this happens, you'll need to examine the MSI log file to determine the failure's cause. You can find the location of the log file in the debug output from either a puppet apply or an agent run; the log file name follows the pattern `puppet-<timestamp>-installer.log`.
* On Windows Server 2003, only x86 is supported, and the `arch` parameter is ignored. If you try to force an upgrade to x64, Puppet installs the x86 version with no error message.
* MSI installation failures do not produce any error. If the install fails, puppet_agent continues to be applied to the agent. If this happens, you'll need to examine the MSI log file to determine the failure's cause. You can find the location of the log file in the debug output from either a puppet apply or an agent run; the log file name follows the pattern `puppet-<timestamp>-installer.log`.
* On Windows Server 2003, only x86 is supported, and the `arch` parameter is ignored. If you try to force an upgrade to x64, Puppet installs the x86 version with no error message.
* On Windows Server 2003 with Puppet Enterprise, the default download location is unreachable. You can work around this issue by specifying an alternate download URL in the `source` parameter.

##Development

Expand Down
8 changes: 0 additions & 8 deletions manifests/config.pp

This file was deleted.

2 changes: 0 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@
else {
class { '::puppet_agent::prepare': } ->
class { '::puppet_agent::install': } ->
class { '::puppet_agent::config': } ~>
class { '::puppet_agent::service': }

contain '::puppet_agent::prepare'
contain '::puppet_agent::install'
contain '::puppet_agent::config'
contain '::puppet_agent::service'
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/prepare/puppet_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Deprecated for global config
'config_version', 'manifest', 'modulepath',
# Settings that should be reset to defaults
'disable_warnings', 'vardir', 'rundir', 'libdir', 'confdir', 'ssldir'].each |$setting| {
'disable_warnings', 'vardir', 'rundir', 'libdir', 'confdir', 'ssldir', 'classfile'].each |$setting| {
ini_setting { "${section}/${setting}":
ensure => absent,
section => $section,
Expand Down
11 changes: 10 additions & 1 deletion manifests/windows/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@
default => $::puppet_agent::arch
}

if $::puppet_agent::is_pe {
$_agent_version = chomp(file('/opt/puppetlabs/puppet/VERSION'))
$_pe_server_version = pe_build_version()
$_https_source = "https://pm.puppetlabs.com/puppet-agent/${_pe_server_version}/${_agent_version}/repos/windows/puppet-agent-${_arch}.msi"
}
else {
$_https_source = "https://downloads.puppetlabs.com/windows/puppet-agent-${_arch}-latest.msi"
}

$_source = $::puppet_agent::source ? {
undef => "https://downloads.puppetlabs.com/windows/puppet-agent-${_arch}-latest.msi",
undef => $_https_source,
/^[a-zA-Z]:/ => windows_native_path($::puppet_agent::source),
default => $::puppet_agent::source,
}
Expand Down
6 changes: 5 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-puppet_agent",
"version": "0.2.0",
"version": "1.0.0",
"author": "puppetlabs",
"summary": "Upgrades Puppet 3.8 to the All-In-One Puppet 4 Agent",
"license": "Apache-2.0",
Expand Down Expand Up @@ -59,6 +59,10 @@
}
],
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.8.1 < 2015.3.0"
},
{
"name": "puppet",
"version_requirement": ">= 3.8.0 < 5.0.0"
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/puppet_agent_prepare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
'vardir',
'rundir',
'libdir',
'confdir'].each do |setting|
'confdir',
'classfile'].each do |setting|
it { is_expected.to contain_ini_setting("#{section}/#{setting}").with_ensure('absent') }
end
end
Expand Down
5 changes: 2 additions & 3 deletions spec/classes/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
it { is_expected.to contain_class('puppet_agent::params') }
if Puppet.version < "4.0.0"
it { is_expected.to contain_class('puppet_agent::prepare') }
it { is_expected.to contain_class('puppet_agent::install').that_comes_before('puppet_agent::config') }
it { is_expected.to contain_class('puppet_agent::config') }
it { is_expected.to contain_class('puppet_agent::service').that_subscribes_to('puppet_agent::config') }
it { is_expected.to contain_class('puppet_agent::install').that_comes_before('puppet_agent::service') }
it { is_expected.to contain_class('puppet_agent::service') }

if params[:service_names].nil?
it { is_expected.to contain_service('puppet') }
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/puppet_agent_windows_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
:puppet_agent_pid => 42,
:system32 => 'C:\windows\sysnative',
} }
context 'is_pe' do
before(:each) do
# Need to mock the function pe_build_version
pe_build_version = {}
file = {}

Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) {
|args| pe_build_version.call()
}
Puppet::Parser::Functions.newfunction(:file, :type => :rvalue) {
|args| file.call(args[0])
}

pe_build_version.stubs(:call).returns('4.0.0')
file.stubs(:call).with('/opt/puppetlabs/puppet/VERSION').returns('1.2.1.1')
end
let(:params) {{ :is_pe => true }}
it {
is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(
%r[#{Regexp.escape("msiexec.exe /qn /norestart /i \"https://pm.puppetlabs.com/puppet-agent/4.0.0/1.2.1.1/repos/windows/puppet-agent-#{values[:expect_arch]}.msi\"")}])
}
end
context 'source =>' do
describe 'https://alterernate.com/puppet-agent.msi' do
let(:params) { {
Expand Down