Skip to content

Commit 29614cb

Browse files
committed
Forget everything
1 parent 2ef2873 commit 29614cb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

plans/add_replica.pp

+14-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
$replica_postgresql_target,
3232
]))
3333

34+
# Get current peadm config to ensure we forget active replicas
35+
$peadm_config = run_task('peadm::get_peadm_config', $primary_target).first.value
36+
37+
# Make list of all possible replicas, configured and provided
38+
$replicas = peadm::flatten_compact([
39+
$replica_host,
40+
$peadm_config['params']['replica_host']
41+
]).unique
42+
3443
$certdata = run_task('peadm::cert_data', $primary_target).first.value
3544
$primary_avail_group_letter = $certdata['extensions'][peadm::oid('peadm_availability_group')]
3645
$replica_avail_group_letter = $primary_avail_group_letter ? { 'A' => 'B', 'B' => 'A' }
@@ -40,7 +49,9 @@
4049
$dns_alt_names = [$replica_target.peadm::certname()] + (pick($certdata['dns-alt-names'], []) - $certdata['certname'])
4150

4251
# This has the effect of revoking the node's certificate, if it exists
43-
run_command("/opt/puppetlabs/bin/puppet infrastructure forget ${replica_target.peadm::certname()}", $primary_target, _catch_errors => true)
52+
$replicas.each |$replica| {
53+
run_command("/opt/puppetlabs/bin/puppet infrastructure forget ${replica}", $primary_target, _catch_errors => true)
54+
}
4455

4556
run_plan('peadm::subplans::component_install', $replica_target,
4657
primary_host => $primary_target,
@@ -76,7 +87,8 @@
7687
server_a_host => $replica_avail_group_letter ? { 'A' => $replica_host, default => undef },
7788
server_b_host => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef },
7889
internal_compiler_a_pool_address => $replica_avail_group_letter ? { 'A' => $replica_host, default => undef },
79-
internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef }
90+
internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef },
91+
peadm_config => $peadm_config
8092
)
8193

8294
# Source the global hiera.yaml from Primary and synchronize to new Replica

0 commit comments

Comments
 (0)