Skip to content

Commit 7a45f3a

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 b01b3df commit 7a45f3a

15 files changed

+211
-24
lines changed

manifests/init.pp

+7
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@
9898
# Puppet_agent::Config hash, which has keys for puppet.conf section, setting, and value.
9999
# This parameter is constrained to managing only a predetermined set of configuration
100100
# settings, e.g. runinterval.
101+
# [alternate_pe_version]
102+
# When using a PE-based package source (e.g. "alternate_pe_source", "aix_source")
103+
# this setting allows you to override the PE version number used when constructing the
104+
# package source URL. Normally, this will be the running version of PE but this setting
105+
# can be used to "hold back" the agents during an upgrade of PE if there is a need
106+
# to upgrade the platform and agents on separate schedules.
101107
class puppet_agent (
102108
$arch = $::architecture,
103109
$collection = $::puppet_agent::params::collection,
@@ -126,6 +132,7 @@
126132
$wait_for_pxp_agent_exit = undef,
127133
$wait_for_puppet_run = undef,
128134
Array[Puppet_agent::Config] $config = [],
135+
Optional[String[1]] $alternate_pe_version = undef,
129136
) inherits ::puppet_agent::params {
130137

131138
# The configure class uses $puppet_agent::config to manage settings in

manifests/osfamily/aix.pp

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

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

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

manifests/osfamily/darwin.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
if $::puppet_agent::absolute_source {
1212
$source = $::puppet_agent::absolute_source
1313
} elsif ($::puppet_agent::is_pe and (!$::puppet_agent::use_alternate_sources)) {
14-
$pe_server_version = pe_build_version()
14+
$pe_server_version = $::puppet_agent::alternate_pe_version.lest || { pe_build_version() }
1515
if $::puppet_agent::alternate_pe_source {
1616
$source = "${::puppet_agent::alternate_pe_source}/packages/${pe_server_version}/${::platform_tag}/${puppet_agent::package_name}-${::puppet_agent::prepare::package_version}-1.osx${$productversion_major}.dmg"
1717
} 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}/${::platform_tag}"
2121
} elsif $::puppet_agent::alternate_pe_source {

manifests/osfamily/redhat.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
}
3030
if ($::puppet_agent::is_pe and (!$::puppet_agent::use_alternate_sources)) {
31-
$pe_server_version = pe_build_version()
31+
$pe_server_version = $::puppet_agent::alternate_pe_version.lest || { pe_build_version() }
3232
# Treat Amazon Linux just like Enterprise Linux
3333
$pe_repo_dir = ($::operatingsystem == 'Amazon') ? {
3434
true => "el-${amz_el_version}-${::architecture}",

manifests/osfamily/solaris.pp

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

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

manifests/osfamily/suse.pp

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

2121
# SLES 11 in PE can no longer install agents from pe_repo
2222
if $::operatingsystemmajrelease == '11' {

manifests/osfamily/windows.pp

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

spec/classes/puppet_agent_osfamily_aix_spec.rb

+25
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,31 @@
8181
}
8282
end
8383

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

spec/classes/puppet_agent_osfamily_darwin_spec.rb

+20
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@
9393
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') }
9494
end
9595

96+
describe 'when using a user defined PE version' do
97+
let(:params) do
98+
{
99+
package_version: '5.10.100.1',
100+
collection: 'puppet5',
101+
alternate_pe_version: '2222.2.2',
102+
}
103+
end
104+
let(:facts) do
105+
facts.merge({
106+
is_pe: true,
107+
aio_agent_version: '1.10.99',
108+
platform_tag: 'osx-10.13-x86_64',
109+
macosx_productversion_major: '10.13'
110+
})
111+
end
112+
113+
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') }
114+
end
115+
96116
describe 'when using package_version auto' do
97117
let(:params) do
98118
{

spec/classes/puppet_agent_osfamily_debian_spec.rb

+22
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,28 @@
233233
}
234234
end
235235

236+
context 'when managing PE apt repo settings and using a user defined PE version' do
237+
let(:params) do
238+
{
239+
manage_repo: true,
240+
package_version: package_version,
241+
alternate_pe_version: '2222.2.2'
242+
}
243+
end
244+
245+
it {
246+
is_expected.to contain_apt__source('pc_repo')
247+
.with({
248+
'location' => 'https://master.example.vm:8140/packages/2222.2.2/debian-7-x86_64',
249+
'repos' => 'PC1',
250+
'key' => {
251+
'id' => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26',
252+
'source' => '/etc/pki/deb-gpg/GPG-KEY-puppet-20250406',
253+
},
254+
})
255+
}
256+
end
257+
236258
context 'when not managing PE apt repo settings' do
237259
let(:params) do
238260
{

spec/classes/puppet_agent_osfamily_redhat_spec.rb

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

196+
context 'when using a user defined PE version' do
197+
let(:params) do
198+
{
199+
package_version: '5.2.0',
200+
manage_repo: true,
201+
alternate_pe_version: '2222.2.2'
202+
}
203+
end
204+
205+
it { is_expected.to contain_yumrepo('pc_repo').with_baseurl("https://master.example.vm:8140/packages/2222.2.2/#{repodir}") }
206+
end
207+
196208
context 'with manage_repo enabled' do
197209
let(:params) do
198210
{

spec/classes/puppet_agent_osfamily_solaris_spec.rb

+48
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,30 @@ def install_script(ver, arch)
138138
end
139139
end
140140

141+
context 'when Solaris 11 i386 and a user defined PE version' do
142+
let(:facts) do
143+
facts.merge({
144+
is_pe: true,
145+
platform_tag: 'solaris-11-i386',
146+
operatingsystemmajrelease: '11',
147+
})
148+
end
149+
let(:params) do
150+
{
151+
package_version: package_version,
152+
alternate_pe_version: '2222.2.2'
153+
}
154+
end
155+
156+
it do
157+
is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p")
158+
.with({
159+
'ensure' => 'present',
160+
'source' => "puppet:///pe_packages/2222.2.2/solaris-11-i386/puppet-agent@#{sol11_package_version},5.11-1.i386.p5p",
161+
})
162+
end
163+
end
164+
141165
context 'when Solaris 11 i386' do
142166
let(:facts) do
143167
facts.merge({
@@ -284,6 +308,30 @@ def install_script(ver, arch)
284308
end
285309
end
286310

311+
context 'when Solaris 10 i386 and a user defined PE version' do
312+
let(:facts) do
313+
facts.merge({
314+
is_pe: true,
315+
platform_tag: 'solaris-10-i386',
316+
operatingsystemmajrelease: '10',
317+
})
318+
end
319+
let(:params) do
320+
{
321+
package_version: package_version,
322+
alternate_pe_version: '2222.2.2'
323+
}
324+
end
325+
326+
it do
327+
is_expected.to contain_file("/opt/puppetlabs/packages/puppet-agent-#{package_version}-1.i386.pkg.gz")
328+
.with({
329+
'ensure' => 'present',
330+
'source' => "puppet:///pe_packages/2222.2.2/solaris-10-i386/puppet-agent-#{package_version}-1.i386.pkg.gz",
331+
})
332+
end
333+
end
334+
287335
context 'when Solaris 10 i386' do
288336
let(:facts) do
289337
facts.merge({

spec/classes/puppet_agent_osfamily_suse_spec.rb

+50-17
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,26 @@
351351
}
352352
end
353353

354+
context 'with manage_repo enabled and a user defined PE version' do
355+
let(:params) do
356+
{
357+
manage_repo: true,
358+
package_version: package_version,
359+
alternate_pe_version: '2222.2.2',
360+
}
361+
end
362+
363+
it {
364+
is_expected.to contain_ini_setting('zypper pc_repo baseurl')
365+
.with({
366+
'path' => '/etc/zypp/repos.d/pc_repo.repo',
367+
'section' => 'pc_repo',
368+
'setting' => 'baseurl',
369+
'value' => "https://master.example.vm:8140/packages/2222.2.2/sles-#{os_version}-x86_64?ssl_verify=no",
370+
})
371+
}
372+
end
373+
354374
it do
355375
is_expected.to contain_package('puppet-agent')
356376
end
@@ -378,23 +398,36 @@
378398
end
379399

380400
describe 'package source', if: os_version == '11' do
381-
it { is_expected.to contain_file('/etc/zypp/repos.d/pc_repo.repo').with({ 'ensure' => 'absent' }) }
382-
it {
383-
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm')
384-
.with(
385-
source: 'puppet:///pe_packages/2000.0.0/sles-11-x86_64/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
386-
)
387-
}
388-
it {
389-
is_expected.to contain_exec('GPG check the RPM file')
390-
.with(
391-
command: 'rpm -K /opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
392-
path: '/bin:/usr/bin:/sbin:/usr/sbin',
393-
require: 'File[/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm]',
394-
logoutput: 'on_failure',
395-
notify: 'Package[puppet-agent]',
396-
)
397-
}
401+
context 'with no source overrides' do
402+
it { is_expected.to contain_file('/etc/zypp/repos.d/pc_repo.repo').with({ 'ensure' => 'absent' }) }
403+
it {
404+
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm')
405+
.with(
406+
source: 'puppet:///pe_packages/2000.0.0/sles-11-x86_64/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
407+
)
408+
}
409+
it {
410+
is_expected.to contain_exec('GPG check the RPM file')
411+
.with(
412+
command: 'rpm -K /opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
413+
path: '/bin:/usr/bin:/sbin:/usr/sbin',
414+
require: 'File[/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm]',
415+
logoutput: 'on_failure',
416+
notify: 'Package[puppet-agent]',
417+
)
418+
}
419+
end
420+
421+
context 'with a user defined PE version' do
422+
let(:params) { super().merge(alternate_pe_version: '2222.2.2') }
423+
424+
it {
425+
is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles11.x86_64.rpm')
426+
.with(
427+
source: 'puppet:///pe_packages/2222.2.2/sles-11-x86_64/puppet-agent-1.10.100-1.sles11.x86_64.rpm',
428+
)
429+
}
430+
end
398431
end
399432
end
400433
end

spec/classes/puppet_agent_osfamily_windows_spec.rb

+20
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@
5151
'source' => "puppet:///pe_packages/#{pe_version}/windows-#{tag}/puppet-agent-#{arch}.msi",
5252
)
5353
}
54+
55+
context 'when alternate_pe_source is supplied' do
56+
let(:params) { super().merge(alternate_pe_source: 'https://fake-package-source.com') }
57+
58+
it {
59+
is_expected.to contain_file("#{appdata}\\Puppetlabs\\packages\\puppet-agent-#{arch}.msi").with(
60+
'source' => "https://fake-package-source.com/packages/#{pe_version}/windows-#{tag}/puppet-agent-#{arch}.msi",
61+
)
62+
}
63+
end
64+
65+
context 'when alternate_pe_version is supplied' do
66+
let(:params) { super().merge(alternate_pe_version: '2222.2.2') }
67+
68+
it {
69+
is_expected.to contain_file("#{appdata}\\Puppetlabs\\packages\\puppet-agent-#{arch}.msi").with(
70+
'source' => "puppet:///pe_packages/2222.2.2/windows-#{tag}/puppet-agent-#{arch}.msi",
71+
)
72+
}
73+
end
5474
end
5575
end
5676

0 commit comments

Comments
 (0)