Showing with 113 additions and 2 deletions.
  1. +8 −0 CHANGELOG.md
  2. +1 −1 manifests/init.pp
  3. +18 −0 manifests/params.pp
  4. +1 −1 metadata.json
  5. +77 −0 spec/classes/puppet_agent_params_spec.rb
  6. +8 −0 spec/spec_helper.rb
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.6.2] - 2018-07-26

### Summary
Compatibility update for PE packaging changes

### Features
- Support for new pe_repo tarballs that use repo names matching open source.

## [1.6.1] - 2018-06-29

### Summary
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#
class puppet_agent (
$arch = $::architecture,
$collection = 'PC1',
$collection = $::puppet_agent::params::collection,
$is_pe = $::puppet_agent::params::_is_pe,
$manage_pki_dir = true,
$manage_repo = true,
Expand Down
18 changes: 18 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@
$package_version = undef
}

# Calculate the default collection
$_pe_version = $_is_pe ? {
true => pe_build_version(),
default => undef
}
# Not PE or pe_version < 2018.1.3, use PC1
if ($_pe_version == undef or versioncmp("${_pe_version}", '2018.1.3') < 0) {
$collection = 'PC1'
}
# 2018.1.3 <= pe_version < 2018.2, use puppet5
elsif versioncmp("${_pe_version}", '2018.2') < 0 {
$collection = 'puppet5'
}
# pe_version >= 2018.2, use puppet6
else {
$collection = 'puppet6'
}

$ssldir = "${confdir}/ssl"
$config = "${confdir}/puppet.conf"

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.6.1",
"version": "1.6.2",
"author": "puppetlabs",
"summary": "Upgrades Puppet 3.7+ and All-In-One Puppet Agents",
"license": "Apache-2.0",
Expand Down
77 changes: 77 additions & 0 deletions spec/classes/puppet_agent_params_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
require 'spec_helper'

describe 'puppet_agent::params' do
let(:facts) do
{
is_pe: true,
clientversion: '5.5.3',
osfamily: 'Debian',
operatingsystem: 'Debian',
servername: 'server',
# custom fact meant to be used only for tests in this file
custom_fact__pe_version: '2018.1.3'
}
end

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue, doc: '') do |args|
lookupvar('::custom_fact__pe_version')
end
end

context 'collection' do
# rspec-puppet lets us query the compiled catalog only, so we can only check if any specific resources
# have been declared. We cannot query for a class' variables, so we cannot query for the collection
# variable's value. But we can use a workaround by creating a notify resource whose message contains
# the value and query that instead since it will be added as part of the catalog. post_condition tells
# rspec-puppet to include this resource only after our class has been compiled, which is what we want.
let(:notify_title) { "check puppet_agent::params::collection's value" }
let(:post_condition) do
<<-NOTIFY_RESOURCE
notify { "#{notify_title}":
message => "${::puppet_agent::params::collection}"
}
NOTIFY_RESOURCE
end

def sets_collection_to(collection)
is_expected.to contain_notify(notify_title).with_message(collection)
end

context 'not in PE' do
let(:facts) { super().merge(is_pe: false, custom_fact__pe_version: '') }

it { sets_collection_to('PC1') }
end

context 'pe_version < 2018.1.3' do
let(:facts) { super().merge(custom_fact__pe_version: '2018.1.2') }

it { sets_collection_to('PC1') }
end

context 'pe_version == 2018.1.3' do
let(:facts) { super().merge(custom_fact__pe_version: '2018.1.3') }

it { sets_collection_to('puppet5') }
end

context '2018.1.3 < pe_version < 2018.2' do
let(:facts) { super().merge(custom_fact__pe_version: '2018.1.5') }

it { sets_collection_to('puppet5') }
end

context 'pe_version == 2018.2' do
let(:facts) { super().merge(custom_fact__pe_version: '2018.2') }

it { sets_collection_to('puppet6') }
end

context 'pe_version > 2018.2' do
let(:facts) { super().merge(custom_fact__pe_version: '2018.3') }

it { sets_collection_to('puppet6') }
end
end
end
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
end
end

RSpec.configure do |c|
c.before :each do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue, doc: '') do |args|
'2018.1.0'
end
end
end

# put local configuration and setup into spec_helper_local
begin
require 'spec_helper_local'
Expand Down