Skip to content

Commit 2d396e9

Browse files
authored
Merge pull request #129 from puppetlabs/fix-upgrade-peconf
Fix upgrade peconf
2 parents 6944b8e + 13f8ab7 commit 2d396e9

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

Diff for: CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# PEADM module
22

3+
## Unreleased
4+
### Summary
5+
6+
Bugfix release
7+
8+
### Bugfixes
9+
10+
- Previously, on upgrade, peadm did not ensure that PostgreSQL servers' pe.conf file contained the critical keys that inform the installer that the system is a stand-alone database. The peadm::upgrade plan now ensures the critical keys are correct as part of the upgrade preparation.
11+
- When upgrading a DR replica to PE 2019.8.0 or 2019.8.1, there is an installer bug that causes the upgrade to fail due to how `puppetdb delete-reports` performs in this configuration. This release works around the problem by bypassing `puppetdb delete-reports`. This workaround will be removed in future releases of peadm after the installer / `puppetdb delete-reports` bug is fixed.
12+
313
## 2.4.0
414
### Summary
515

Diff for: functions/validate_version.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function peadm::validate_version(
22
String $version,
33
) {
4-
$supported = ($version =~ SemVerRange('>= 2019.7.0 < 2019.9.0'))
4+
$supported = ($version =~ SemVerRange('>= 2019.7.0 <= 2019.8.1'))
55
66
unless $supported {
77
fail(@("REASON"/L))
@@ -10,7 +10,7 @@ function peadm::validate_version(
1010
For PE versions older than 2019.7, please use version 1.x of the \
1111
puppetlabs-peadm module.
1212

13-
For PE versions newer than 2019.8.x, check to see if a new version of peadm \
13+
For PE versions newer than 2019.8.1, check to see if a new version of peadm \
1414
exists which supports that version of PE.
1515

1616
| REASON

Diff for: lib/puppet/functions/peadm/parsehocon.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
4+
Puppet::Functions.create_function(:'peadm::parsehocon') do
5+
dispatch :parsehocon do
6+
param 'String', :hocon_string
7+
end
8+
9+
def parsehocon(hocon_string)
10+
require 'hocon/config_factory'
11+
12+
data = Hocon::ConfigFactory.parse_string(hocon_string)
13+
data.resolve.root.unwrapped
14+
end
15+
end

Diff for: plans/upgrade.pp

+57-1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,37 @@
143143
# task for idempotency reasons. When the orchestrator has been upgraded but
144144
# not all pxp-agents have, the built-in service task does not work over pcp.
145145
run_command('systemctl stop puppet', $all_targets)
146+
147+
# Create a variable for configuring PuppetDB access for all the certnames
148+
# that are known to need it.
149+
$profile_database_puppetdb_hosts = {
150+
'puppet_enterprise::profile::database::puppetdb_hosts' => (
151+
$compiler_targets + $master_target + $master_replica_target
152+
).map |$t| { $t.peadm::target_name() },
153+
}
154+
155+
# Ensure the pe.conf files on the PostgreSQL node(s) are correct. This file
156+
# is only ever consulted during install and upgrade of these nodes, but if
157+
# it contains the wrong values, upgrade will fail.
158+
peadm::flatten_compact([
159+
$puppetdb_database_target,
160+
$puppetdb_database_replica_target,
161+
]).each |$target| {
162+
$current_pe_conf = run_task('peadm::read_file', $target,
163+
path => '/etc/puppetlabs/enterprise/conf.d/pe.conf',
164+
).first['content']
165+
166+
$pe_conf = ($current_pe_conf ? {
167+
undef => {},
168+
default => $current_pe_conf.peadm::parsehocon(),
169+
} + {
170+
'console_admin_password' => 'not used',
171+
'puppet_enterprise::puppet_master_host' => $master_target.peadm::target_name(),
172+
'puppet_enterprise::database_host' => $target.peadm::target_name(),
173+
} + $profile_database_puppetdb_hosts).to_json_pretty()
174+
175+
write_file($pe_conf, '/etc/puppetlabs/enterprise/conf.d/pe.conf', $target)
176+
}
146177
}
147178

148179
peadm::plan_step('upgrade-primary') || {
@@ -242,12 +273,37 @@
242273
$puppetdb_database_replica_target,
243274
]))
244275

245-
# Upgrade the master replica
276+
# The `puppetdb delete-reports` CLI app has a bug in 2019.8.0 where it
277+
# doesn't deal well with the PuppetDB database being on a separate node.
278+
# So, move it aside before running the upgrade.
279+
$pdbapps = '/opt/puppetlabs/server/apps/puppetdb/cli/apps'
280+
$workaround_delete_reports = $arch['high-availability'] and $version =~ SemVerRange('>= 2019.8')
281+
if $workaround_delete_reports {
282+
run_command(@("COMMAND"/$), $master_replica_target)
283+
if [ -e ${pdbapps}/delete-reports -a ! -h ${pdbapps}/delete-reports ]
284+
then
285+
mv ${pdbapps}/delete-reports ${pdbapps}/delete-reports.original
286+
ln -s \$(which true) ${pdbapps}/delete-reports
287+
fi
288+
| COMMAND
289+
}
290+
291+
# Upgrade the master replica.
246292
run_task('peadm::puppet_infra_upgrade', $master_target,
247293
type => 'replica',
248294
targets => $master_replica_target.map |$t| { $t.peadm::target_name() },
249295
token_file => $token_file,
250296
)
297+
298+
# Return the delete-reports CLI app to its original state
299+
if $workaround_delete_reports {
300+
run_command(@("COMMAND"/$), $master_replica_target)
301+
if [ -e ${pdbapps}/delete-reports.original ]
302+
then
303+
mv ${pdbapps}/delete-reports.original ${pdbapps}/delete-reports
304+
fi
305+
| COMMAND
306+
}
251307
}
252308

253309
peadm::plan_step('upgrade-replica-compilers') || {

0 commit comments

Comments
 (0)