Skip to content

Commit e3036c8

Browse files
committed
(PE-39215) Retreiving replica postgres from get_peadm_config - add_replica
No longer requiring user to input replica postgres host and instead getting this from peadm config
1 parent b07439a commit e3036c8

File tree

6 files changed

+7
-32
lines changed

6 files changed

+7
-32
lines changed

REFERENCE.md

-10
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,6 @@ The following parameters are available in the `peadm::add_replica` plan:
17881788

17891789
* [`primary_host`](#-peadm--add_replica--primary_host)
17901790
* [`replica_host`](#-peadm--add_replica--replica_host)
1791-
* [`replica_postgresql_host`](#-peadm--add_replica--replica_postgresql_host)
17921791
* [`token_file`](#-peadm--add_replica--token_file)
17931792

17941793
##### <a name="-peadm--add_replica--primary_host"></a>`primary_host`
@@ -1803,15 +1802,6 @@ Data type: `Peadm::SingleTargetSpec`
18031802

18041803
- The hostname and certname of the replica VM
18051804

1806-
##### <a name="-peadm--add_replica--replica_postgresql_host"></a>`replica_postgresql_host`
1807-
1808-
Data type: `Optional[Peadm::SingleTargetSpec]`
1809-
1810-
- The hostname and certname of the host with the replica PE-PosgreSQL database.
1811-
Can be a separate host in an XL architecture, or undef in Standard or Large.
1812-
1813-
Default value: `undef`
1814-
18151805
##### <a name="-peadm--add_replica--token_file"></a>`token_file`
18161806

18171807
Data type: `Optional[String]`

documentation/add_replica.md

-6
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ The plan performs the following steps:
6464
- **Description:**
6565
The hostname and certname of the replica VM.
6666

67-
### `primary_postgresql_host`
68-
69-
- **Type:** `Optional[Peadm::SingleTargetSpec]`
70-
- **Description:**
71-
The target specification for the primary PostgreSQL host that the new replica will synchronize with. This is the database server from which the replica will replicate data.
72-
7367
### `token_file`
7468

7569
- **Type:** `Optional[String]`

documentation/automated_recovery.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Manual procedures are documented in [recovery.md](recovery.md)
1414
This procedure uses the following placeholder references.
1515

1616
* _\<primary-server-fqdn\>_ - The FQDN and certname of the primary Puppet server
17-
* _\<replica-postgres-server-fqdn\>_ - The FQDN and certname of the PE-PostgreSQL server which resides in the same availability group as the replacement replica Puppet server
1817
* _\<replacement-replica-fqdn\>_ - The FQDN and certname of the replacement replica Puppet server
1918

2019
1. Run `peadm::add_replica` plan to deploy replacement replica Puppet server
@@ -24,7 +23,7 @@ This procedure uses the following placeholder references.
2423

2524
2. For Extra Large deployments
2625

27-
bolt plan run peadm::add_replica primary_host=<primary-server-fqdn> replica_host=<replacement-replica-fqdn> replica_postgresql_host=<replica-postgres-server-fqdn>
26+
bolt plan run peadm::add_replica primary_host=<primary-server-fqdn> replica_host=<replacement-replica-fqdn>
2827

2928
## Replace failed PE-PostgreSQL server (A or B side)
3029

plans/add_replica.pp

+6-10
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,34 @@
44
# 2: The existing replica is broken, we have a fresh new VM we want to provision the replica to.
55
# @param primary_host - The hostname and certname of the primary Puppet server
66
# @param replica_host - The hostname and certname of the replica VM
7-
# @param replica_postgresql_host - The hostname and certname of the host with the replica PE-PosgreSQL database.
8-
# Can be a separate host in an XL architecture, or undef in Standard or Large.
97
# @param token_file - (optional) the token file in a different location than the default.
108
plan peadm::add_replica(
119
# Standard or Large
1210
Peadm::SingleTargetSpec $primary_host,
1311
Peadm::SingleTargetSpec $replica_host,
1412

15-
# Extra Large
16-
Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef,
17-
1813
# Common Configuration
1914
Optional[String] $token_file = undef,
2015
) {
2116
$primary_target = peadm::get_targets($primary_host, 1)
2217
$replica_target = peadm::get_targets($replica_host, 1)
23-
$replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1)
2418

2519
$code_manager_enabled = run_task('peadm::code_manager_enabled', $primary_target).first.value['code_manager_enabled']
2620

2721
if $code_manager_enabled == false {
2822
fail('Code Manager must be enabled to add a replica. Please refer to the docs for more information on enabling Code Manager.')
2923
}
3024

25+
# Get current peadm config to ensure we forget active replicas
26+
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value
27+
28+
$replica_postgresql_target = $peadm_config['params']['replica_postgresql_host']
29+
3130
run_command('systemctl stop puppet.service', peadm::flatten_compact([
3231
$primary_target,
3332
$replica_postgresql_target,
3433
]))
3534

36-
# Get current peadm config to ensure we forget active replicas
37-
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value
38-
3935
# Make list of all possible replicas, configured and provided
4036
$replicas = peadm::flatten_compact([
4137
$replica_host,
@@ -65,7 +61,7 @@
6561
# Wrap these things that operate on replica_postgresql_target in an if statement
6662
# to avoid failures retrieving PSQL version because you can't operate functions
6763
# on a return value of nil.
68-
if $replica_postgresql_host {
64+
if $replica_postgresql_target {
6965
# On the PE-PostgreSQL server in the <replacement-avail-group-letter> group
7066
$psql_version = run_task('peadm::get_psql_version', $replica_postgresql_target).first.value['version']
7167

spec/acceptance/peadm_spec/plans/add_replica.pp

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
$primary_host = $t.filter |$n| { $n.vars['role'] == 'primary' }
1212
$replica_host = $t.filter |$n| { $n.vars['role'] == 'spare-replica' }
13-
$replica_postgresql_host = $t.filter |$n| { $n.vars['role'] == 'replica-pdb-postgresql' }
1413

1514
if $replica_host == [] {
1615
fail_plan('"replica" role missing from inventory, cannot continue')
@@ -19,6 +18,5 @@
1918
run_plan('peadm::add_replica',
2019
primary_host => $primary_host,
2120
replica_host => $replica_host,
22-
replica_postgresql_host => $replica_postgresql_host ? { [] => undef, default => $replica_postgresql_host },
2321
)
2422
}

spec/acceptance/peadm_spec/plans/perform_failover.pp

-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
out::message("Active nodes 2: ${res2.first['stdout']}")
6060

6161
# add new replica
62-
$replica_postgresql_host = $t.filter |$n| { $n.vars['role'] == 'primary-pdb-postgresql' }[0]
6362
$new_replica_host = $t.filter |$n| { $n.vars['role'] == 'spare-replica' }[0]
6463

6564
if $new_replica_host == [] {
@@ -76,7 +75,6 @@
7675
run_plan('peadm::add_replica',
7776
primary_host => $replica_host.uri,
7877
replica_host => $new_replica_host.uri,
79-
replica_postgresql_host => $replica_postgresql_host ? {[] => undef, default => $replica_postgresql_host.uri },
8078
)
8179

8280
$res3 = run_command("/opt/puppetlabs/bin/puppet query \'${query}\'", $replica_host)

0 commit comments

Comments
 (0)