Skip to content

Commit 9c0a7d2

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 9c0a7d2

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

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]`

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

0 commit comments

Comments
 (0)