Skip to content

Commit 113b47a

Browse files
committed
Provide ability to override db settings
Capability to set PuppetDB database backend address to anything. Previously, peadm::util::update_db_setting would always attempt to pair configuration with appropriate availability group letter but in DR scenarios this is not appropriate.
1 parent 39e7708 commit 113b47a

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

documentation/automated_recovery.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Procedure:
2222

2323
2. Temporarily set both primary and replica server nodes so that they use the remaining healthy PE-PostgreSQL server
2424

25-
bolt plan run peadm::util::update_db_setting --target <primary-server-fqdn>,<replica-server-fqdn> primary_postgresql_host=<working-postgres-server-fqdn>
25+
bolt plan run peadm::util::update_db_setting --target <primary-server-fqdn>,<replica-server-fqdn> primary_postgresql_host=<working-postgres-server-fqdn> override=true
2626

2727
3. Restart `pe-puppetdb.service` on Puppet server primary and replica
2828

plans/util/update_db_setting.pp

+19-14
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,33 @@
66
TargetSpec $targets,
77
Optional[Peadm::SingleTargetSpec] $postgresql_host = undef,
88
Optional[Hash] $peadm_config = undef,
9+
Boolean $override = false
910
) {
1011

1112
# FIX ME: Section needs to be parallelized, can't use built in functionality
1213
# of apply().
1314
get_targets($targets).each |$target| {
1415

15-
# Existing config used to dynamically pair nodes with appropriate PSQL
16-
# server
17-
$roles = $peadm_config['role-letter']
16+
if $override {
17+
$db = $postgresql_host
18+
} else {
19+
# Existing config used to dynamically pair nodes with appropriate PSQL
20+
# server
21+
$roles = $peadm_config['role-letter']
1822

19-
# Determine configuration by pairing target with existing availability letter
20-
# assignments, setting to the new node if no match is found.
21-
$target_group_letter = peadm::flatten_compact([$roles['compilers'],$roles['server']].map |$role| {
22-
$role.map |$k,$v| {
23-
if $target.peadm::certname() in $v { $k }
23+
# Determine configuration by pairing target with existing availability letter
24+
# assignments, setting to the new node if no match is found.
25+
$target_group_letter = peadm::flatten_compact([$roles['compilers'],$roles['server']].map |$role| {
26+
$role.map |$k,$v| {
27+
if $target.peadm::certname() in $v { $k }
28+
}
29+
})[0]
30+
$match = $roles['postgresql'][$target_group_letter]
31+
if $match {
32+
$db = $match
33+
} else {
34+
$db = $postgresql_host
2435
}
25-
})[0]
26-
$match = $roles['postgresql'][$target_group_letter]
27-
if $match {
28-
$db = $match
29-
} else {
30-
$db = $postgresql_host
3136
}
3237

3338
$db_setting = "//${db}:5432/pe-puppetdb?ssl=true&sslfactory=org.postgresql.ssl.jdbc4.LibPQFactory&sslmode=verify-full&sslrootcert=/etc/puppetlabs/puppet/ssl/certs/ca.pem&sslkey=/etc/puppetlabs/puppetdb/ssl/${target.peadm::certname()}.private_key.pk8&sslcert=/etc/puppetlabs/puppetdb/ssl/${$target.peadm::certname()}.cert.pem"

0 commit comments

Comments
 (0)