Skip to content

Commit c1e0210

Browse files
committed
(MODULES-10670) Add alternate_pe_version parameter
This parameter will allow PE users to override the PE version detection used in the packages source to a different version than the running PE version. This could be used to hold back packages during a PE upgrade cycle until the user is ready to upgrade the agents.
1 parent 2920159 commit c1e0210

15 files changed

+205
-25
lines changed

manifests/init.pp

+8-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
# @param skip_if_unavailable
104104
# For yum-based repositories, set the skip_if_unavailable option of the `yumrepo` type.
105105
# @param disable_proxy
106+
# @param alternate_pe_version
107+
# When using a PE-based package source (e.g. "alternate_pe_source", "aix_source")
108+
# this setting allows you to override the PE version number used when constructing the
109+
# package source URL. Normally, this will be the running version of PE but this setting
110+
# can be used to "hold back" the agents during an upgrade of PE if there is a need
111+
# to upgrade the platform and agents on separate schedules.
106112
class puppet_agent (
107113
String $arch = $facts['os']['architecture'],
108114
String $collection = $puppet_agent::params::collection,
@@ -131,7 +137,8 @@
131137
Optional $wait_for_pxp_agent_exit = undef,
132138
Optional $wait_for_puppet_run = undef,
133139
Array[Puppet_agent::Config] $config = [],
134-
String $version_file_path = $facts['os']['family'] ? { 'windows' => "${facts['env_windows_installdir']}\\VERSION", default => '/opt/puppetlabs/puppet/VERSION' }
140+
String $version_file_path = $facts['os']['family'] ? { 'windows' => "${facts['env_windows_installdir']}\\VERSION", default => '/opt/puppetlabs/puppet/VERSION' },
141+
Optional[String[1]] $alternate_pe_version = undef,
135142
) inherits puppet_agent::params {
136143
# The configure class uses $puppet_agent::config to manage settings in
137144
# puppet.conf, and will always be present. It does not require management of

manifests/osfamily/aix.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
fail('AIX upgrades are only supported on Puppet Enterprise')
1111
}
1212

13-
$pe_server_version = pe_build_version()
13+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
1414

1515
# in puppet versions later than 4 we began using single agent packages for
1616
# multiple version of AIX. The support sequence is as follows:

manifests/osfamily/darwin.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if $puppet_agent::absolute_source {
1313
$source = $puppet_agent::absolute_source
1414
} elsif ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
15-
$pe_server_version = pe_build_version()
15+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
1616
if $puppet_agent::alternate_pe_source {
1717
$source = "${puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${facts['platform_tag']}/${puppet_agent::package_name}-${puppet_agent::prepare::package_version}-1.osx${$productversion_major}.dmg"
1818
} elsif $puppet_agent::source {

manifests/osfamily/debian.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
if getvar('::puppet_agent::manage_repo') == true {
1616
include apt
1717
if ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
18-
$pe_server_version = pe_build_version()
18+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
1919
if $puppet_agent::source {
2020
$source = "${puppet_agent::source}/packages/${pe_server_version}/${facts['platform_tag']}"
2121
} elsif $puppet_agent::alternate_pe_source {

manifests/osfamily/redhat.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
# lint:endignore
3333
if ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
34-
$pe_server_version = pe_build_version()
34+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
3535
# Treat Amazon Linux just like Enterprise Linux
3636
$pe_repo_dir = ($facts['os']['name'] == 'Amazon') ? {
3737
true => "el-${amz_el_version}-${facts['os']['architecture']}",

manifests/osfamily/solaris.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
fail('Solaris upgrades are only supported on Puppet Enterprise')
1111
}
1212

13-
$pe_server_version = pe_build_version()
13+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
1414
if $puppet_agent::absolute_source {
1515
$source_dir = $puppet_agent::absolute_source
1616
} elsif $puppet_agent::alternate_pe_source {

manifests/osfamily/suse.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
contain puppet_agent::prepare::package
1818
} else {
1919
if ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
20-
$pe_server_version = pe_build_version()
20+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
2121

2222
# SLES 11 in PE can no longer install agents from pe_repo
2323
if $facts['os']['release']['major'] == '11' {

manifests/osfamily/windows.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
} elsif $puppet_agent::source {
88
$source = $puppet_agent::source
99
} elsif ($puppet_agent::is_pe and (!$puppet_agent::use_alternate_sources)) {
10-
$pe_server_version = pe_build_version()
10+
$pe_server_version = $puppet_agent::alternate_pe_version.lest || { pe_build_version() }
1111
$tag = $puppet_agent::arch ? {
1212
'x64' => $facts['fips_enabled'] ? {
1313
true => 'windowsfips-x86_64',

spec/classes/puppet_agent_osfamily_aix_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@
8080
}
8181
end
8282

83+
context 'with a user defined PE version' do
84+
let(:facts) do
85+
common_facts.merge(
86+
{
87+
architecture: 'PowerPC_POWER8',
88+
platform_tag: 'aix-7.1-power',
89+
}
90+
)
91+
end
92+
let(:params) do
93+
{
94+
package_version: '7.10.100.1',
95+
collection: 'puppet7',
96+
alternate_pe_version: '2222.2.2',
97+
}
98+
end
99+
100+
before(:each) do
101+
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
102+
end
103+
104+
it {
105+
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm').with_source('puppet:///pe_packages/2222.2.2/aix-7.1-power/puppet-agent-7.10.100.1-1.aix7.1.ppc.rpm')
106+
}
107+
end
108+
83109
context 'with a puppet6 collection' do
84110
context 'with versions up to 6.19.1' do
85111
let(:params) do

spec/classes/puppet_agent_osfamily_darwin_spec.rb

+20
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@
8484
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg').with_source('https://fake-pe-master.com/packages/2000.0.0/osx-10.13-x86_64/puppet-agent-5.10.100.1-1.osx10.13.dmg') }
8585
end
8686

87+
describe 'when using a user defined PE version' do
88+
let(:params) do
89+
{
90+
package_version: '5.10.100.1',
91+
collection: 'puppet5',
92+
alternate_pe_version: '2222.2.2',
93+
}
94+
end
95+
let(:facts) do
96+
facts.merge({
97+
is_pe: true,
98+
aio_agent_version: '1.10.99',
99+
platform_tag: 'osx-10.13-x86_64',
100+
macosx_productversion_major: '10.13'
101+
})
102+
end
103+
104+
it { is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-5.10.100.1-1.osx10.13.dmg').with_source('puppet:///pe_packages/2222.2.2/osx-10.13-x86_64/puppet-agent-5.10.100.1-1.osx10.13.dmg') }
105+
end
106+
87107
describe 'when using package_version auto' do
88108
let(:params) do
89109
{

spec/classes/puppet_agent_osfamily_debian_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,28 @@
216216
}
217217
end
218218

219+
context 'when managing PE apt repo settings and using a user defined PE version' do
220+
let(:params) do
221+
{
222+
manage_repo: true,
223+
package_version: package_version,
224+
alternate_pe_version: '2222.2.2'
225+
}
226+
end
227+
228+
it {
229+
is_expected.to contain_apt__source('pc_repo')
230+
.with({
231+
'location' => 'https://master.example.vm:8140/packages/2222.2.2/debian-7-x86_64',
232+
'repos' => 'PC1',
233+
'key' => {
234+
'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26',
235+
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet-20250406',
236+
},
237+
})
238+
}
239+
end
240+
219241
context 'when not managing PE apt repo settings' do
220242
let(:params) do
221243
{

spec/classes/puppet_agent_osfamily_redhat_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@
186186
it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("http://fake-pe-master.com/packages/2000.0.0/#{repodir}") }
187187
end
188188

189+
context 'when using a user defined PE version' do
190+
let(:params) do
191+
{
192+
package_version: '5.2.0',
193+
manage_repo: true,
194+
alternate_pe_version: '2222.2.2'
195+
}
196+
end
197+
198+
it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("https://master.example.vm:8140/packages/2222.2.2/#{repodir}") }
199+
end
200+
189201
context 'with manage_repo enabled' do
190202
let(:params) do
191203
{

spec/classes/puppet_agent_osfamily_solaris_spec.rb

+40
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,26 @@ def install_script(ver, arch)
125125
end
126126
end
127127

128+
context 'when Solaris 11 i386 and a user defined PE version' do
129+
let(:facts) do
130+
override_facts(facts, is_pe: true, os: { release: { major: '11', }, }, platform_tag: 'solaris-11-i386')
131+
end
132+
let(:params) do
133+
{
134+
package_version: package_version,
135+
alternate_pe_version: '2222.2.2'
136+
}
137+
end
138+
139+
it do
140+
is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p")
141+
.with({
142+
'ensure' => 'file',
143+
'source' => "puppet:///pe_packages/2222.2.2/solaris-11-i386/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p",
144+
})
145+
end
146+
end
147+
128148
context 'when Solaris 11 i386' do
129149
let(:facts) do
130150
override_facts(facts, is_pe: true, os: { release: { major: '11', }, }, platform_tag: 'solaris-11-i386')
@@ -258,6 +278,26 @@ def install_script(ver, arch)
258278
end
259279
end
260280

281+
context 'when Solaris 10 i386 and a user defined PE version' do
282+
let(:facts) do
283+
override_facts(facts, is_pe: true, os: { release: { major: '10', }, }, platform_tag: 'solaris-10-i386')
284+
end
285+
let(:params) do
286+
{
287+
package_version: package_version,
288+
alternate_pe_version: '2222.2.2'
289+
}
290+
end
291+
292+
it do
293+
is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg.gz")
294+
.with({
295+
'ensure' => 'file',
296+
'source' => "puppet:///pe_packages/2222.2.2/solaris-10-i386/puppet-agent-#{package_version}-1.i386.pkg.gz",
297+
})
298+
end
299+
end
300+
261301
context 'when Solaris 10 i386' do
262302
let(:facts) do
263303
override_facts(facts, is_pe: true, os: { release: { major: '10', }, }, platform_tag: 'solaris-10-i386')

spec/classes/puppet_agent_osfamily_suse_spec.rb

+50-17
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@
342342
}
343343
end
344344

345+
context 'with manage_repo enabled and a user defined PE version' do
346+
let(:params) do
347+
{
348+
manage_repo: true,
349+
package_version: package_version,
350+
alternate_pe_version: '2222.2.2',
351+
}
352+
end
353+
354+
it {
355+
is_expected.to contain_ini_setting('zypper pc_repo baseurl')
356+
.with({
357+
'path' => '/etc/zypp/repos.d/pc_repo.repo',
358+
'section' => 'pc_repo',
359+
'setting' => 'baseurl',
360+
'value' => "https://master.example.vm:8140/packages/2222.2.2/sles-#{os_version}-x86_64?ssl_verify=no",
361+
})
362+
}
363+
end
364+
345365
it do
346366
is_expected.to contain_package('puppet-agent')
347367
end
@@ -369,23 +389,36 @@
369389
end
370390

371391
describe 'package source', if: os_version == '11' do
372-
it { is_expected.to contain_file('/etc/zypp/repos.d/pc_repo.repo').with({ 'ensure' => 'absent' }) }
373-
it {
374-
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm')
375-
.with(
376-
source: 'puppet:///pe_packages/2000.0.0/sles-11-x86_64/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
377-
)
378-
}
379-
it {
380-
is_expected.to contain_exec('GPG check the RPM file')
381-
.with(
382-
command: 'rpm -K /opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
383-
path: '/bin:/usr/bin:/sbin:/usr/sbin',
384-
require: 'File[/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm]',
385-
logoutput: 'on_failure',
386-
notify: 'Package[puppet-agent]',
387-
)
388-
}
392+
context 'with no source overrides' do
393+
it { is_expected.to contain_file('/etc/zypp/repos.d/pc_repo.repo').with({ 'ensure' => 'absent' }) }
394+
it {
395+
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm')
396+
.with(
397+
source: 'puppet:///pe_packages/2000.0.0/sles-11-x86_64/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
398+
)
399+
}
400+
it {
401+
is_expected.to contain_exec('GPG check the RPM file')
402+
.with(
403+
command: 'rpm -K /opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
404+
path: '/bin:/usr/bin:/sbin:/usr/sbin',
405+
require: 'File[/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm]',
406+
logoutput: 'on_failure',
407+
notify: 'Package[puppet-agent]',
408+
)
409+
}
410+
end
411+
412+
context 'with a user defined PE version' do
413+
let(:params) { super().merge(alternate_pe_version: '2222.2.2') }
414+
415+
it {
416+
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm')
417+
.with(
418+
source: 'puppet:///pe_packages/2222.2.2/sles-11-x86_64/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
419+
)
420+
}
421+
end
389422
end
390423
end
391424
end

spec/classes/puppet_agent_osfamily_windows_spec.rb

+20
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@
5656
'source' => "puppet:///pe_packages/#{pe_version}/windows-#{tag}/puppet-agent-#{arch}.msi",
5757
)
5858
}
59+
60+
context 'when alternate_pe_source is supplied' do
61+
let(:params) { super().merge(alternate_pe_source: 'https://fake-package-source.com') }
62+
63+
it {
64+
is_expected.to contain_file("#{appdata}\\Puppetlabs\\packages\\puppet-agent-#{arch}.msi").with(
65+
'source' => "https://fake-package-source.com/packages/#{pe_version}/windows-#{tag}/puppet-agent-#{arch}.msi",
66+
)
67+
}
68+
end
69+
70+
context 'when alternate_pe_version is supplied' do
71+
let(:params) { super().merge(alternate_pe_version: '2222.2.2') }
72+
73+
it {
74+
is_expected.to contain_file("#{appdata}\\Puppetlabs\\packages\\puppet-agent-#{arch}.msi").with(
75+
'source' => "puppet:///pe_packages/2222.2.2/windows-#{tag}/puppet-agent-#{arch}.msi",
76+
)
77+
}
78+
end
5979
end
6080
end
6181

0 commit comments

Comments
 (0)