|
4 | 4 | # 2: The existing replica is broken, we have a fresh new VM we want to provision the replica to.
|
5 | 5 | # @param primary_host - The hostname and certname of the primary Puppet server
|
6 | 6 | # @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. |
9 | 7 | # @param token_file - (optional) the token file in a different location than the default.
|
10 | 8 | plan peadm::add_replica(
|
11 | 9 | # Standard or Large
|
12 | 10 | Peadm::SingleTargetSpec $primary_host,
|
13 | 11 | Peadm::SingleTargetSpec $replica_host,
|
14 | 12 |
|
15 |
| - # Extra Large |
16 |
| - Optional[Peadm::SingleTargetSpec] $replica_postgresql_host = undef, |
17 |
| - |
18 | 13 | # Common Configuration
|
19 | 14 | Optional[String] $token_file = undef,
|
20 | 15 | ) {
|
21 | 16 | $primary_target = peadm::get_targets($primary_host, 1)
|
22 | 17 | $replica_target = peadm::get_targets($replica_host, 1)
|
23 |
| - $replica_postgresql_target = peadm::get_targets($replica_postgresql_host, 1) |
24 | 18 |
|
25 | 19 | $code_manager_enabled = run_task('peadm::code_manager_enabled', $primary_target).first.value['code_manager_enabled']
|
26 | 20 |
|
27 | 21 | if $code_manager_enabled == false {
|
28 | 22 | fail('Code Manager must be enabled to add a replica. Please refer to the docs for more information on enabling Code Manager.')
|
29 | 23 | }
|
30 | 24 |
|
| 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 | + |
31 | 30 | run_command('systemctl stop puppet.service', peadm::flatten_compact([
|
32 | 31 | $primary_target,
|
33 | 32 | $replica_postgresql_target,
|
34 | 33 | ]))
|
35 | 34 |
|
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 |
| - |
39 | 35 | # Make list of all possible replicas, configured and provided
|
40 | 36 | $replicas = peadm::flatten_compact([
|
41 | 37 | $replica_host,
|
|
65 | 61 | # Wrap these things that operate on replica_postgresql_target in an if statement
|
66 | 62 | # to avoid failures retrieving PSQL version because you can't operate functions
|
67 | 63 | # on a return value of nil.
|
68 |
| - if $replica_postgresql_host { |
| 64 | + if $replica_postgresql_target { |
69 | 65 | # On the PE-PostgreSQL server in the <replacement-avail-group-letter> group
|
70 | 66 | $psql_version = run_task('peadm::get_psql_version', $replica_postgresql_target).first.value['version']
|
71 | 67 |
|
|
0 commit comments