Skip to content

Commit feedad6

Browse files
committed
Ensure global hiera is synced to new replicas
Creates a utility plan that is used by add_replica plan to source the primary's global hiera configuration and distribute it to replicat target. Without this, data in the console is not available when compiling catalogs after replica is promoted.
1 parent ebb96d1 commit feedad6

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

plans/add_replica.pp

+6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef }
8080
)
8181

82+
# Source the global hiera.yaml from Primary and synchronize to new Replica
83+
# Provision the new system as a replica
84+
run_plan('peadm::util::sync_global_hiera', $replica_target,
85+
primary_host => $primary_target
86+
)
87+
8288
# Provision the new system as a replica
8389
run_task('peadm::provision_replica', $primary_target,
8490
replica => $replica_target.peadm::certname(),

plans/util/sync_global_hiera.pp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# @api private
2+
plan peadm::util::sync_global_hiera (
3+
Peadm::SingleTargetSpec $targets,
4+
Peadm::SingleTargetSpec $primary_host,
5+
) {
6+
7+
$primary_target = peadm::get_targets($primary_host, 1)
8+
$replica_target = $targets
9+
10+
# Source the global hiera.yaml from Primary and synchronize to new Replica
11+
$global_hiera_yaml = run_task('peadm::read_file', $primary_target,
12+
path => '/etc/puppetlabs/puppet/hiera.yaml',
13+
).first['content']
14+
15+
run_task('peadm::mkdir_p_file', $replica_target,
16+
path => '/etc/puppetlabs/puppet/hiera.yaml',
17+
owner => 'root',
18+
group => 'root',
19+
mode => '0644',
20+
content => $global_hiera_yaml,
21+
)
22+
}

spec/plans/add_replica_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def allow_standard_non_returning_calls
1717
it 'runs successfully when the primary does not have alt-names' do
1818
allow_standard_non_returning_calls
1919
expect_task('peadm::get_peadm_config').always_return(cfg)
20-
expect_task('peadm::cert_data').always_return(certdata).be_called_times(3)
20+
expect_task('peadm::cert_data').always_return(certdata).be_called_times(4)
2121
expect_task('package').always_return({ 'status' => 'uninstalled' })
2222
expect_task('peadm::agent_install')
2323
.with_params({ 'server' => 'primary',
@@ -35,7 +35,7 @@ def allow_standard_non_returning_calls
3535
it 'runs successfully when the primary has alt-names' do
3636
allow_standard_non_returning_calls
3737
expect_task('peadm::get_peadm_config').always_return(cfg)
38-
expect_task('peadm::cert_data').always_return(certdata.merge({ 'dns-alt-names' => ['primary', 'alt'] })).be_called_times(3)
38+
expect_task('peadm::cert_data').always_return(certdata.merge({ 'dns-alt-names' => ['primary', 'alt'] })).be_called_times(4)
3939
expect_task('package').always_return({ 'status' => 'uninstalled' })
4040
expect_task('peadm::agent_install')
4141
.with_params({ 'server' => 'primary',

0 commit comments

Comments
 (0)