Skip to content

Commit 321e084

Browse files
Merge pull request #281 from ody/sync_other_items
Re-use sync_global_hiera plan
2 parents 21736d1 + 7704c0c commit 321e084

File tree

8 files changed

+65
-51
lines changed

8 files changed

+65
-51
lines changed

plans/add_compiler.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@
111111
)
112112

113113
# Source the global hiera.yaml from Primary and synchronize to new compiler
114-
run_plan('peadm::util::sync_global_hiera', $compiler_target,
115-
primary_host => $primary_target
114+
run_plan('peadm::util::copy_file', $compiler_target,
115+
source_host => $primary_target,
116+
path => '/etc/puppetlabs/puppet/hiera.yaml'
116117
)
117118

118119
# On <compiler-host>, run the puppet agent

plans/add_replica.pp

+14-5
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,20 @@
9797
peadm_config => $peadm_config
9898
)
9999

100-
# Source the global hiera.yaml from Primary and synchronize to new Replica
101-
# Provision the new system as a replica
102-
run_plan('peadm::util::sync_global_hiera', $replica_target,
103-
primary_host => $primary_target
104-
)
100+
# Source list of files on Primary and synchronize to new Replica
101+
$content_sources = [
102+
'/opt/puppetlabs/server/data/console-services/certs/ad_ca_chain.pem',
103+
'/etc/puppetlabs/orchestration-services/conf.d/secrets/keys.json',
104+
'/etc/puppetlabs/orchestration-services/conf.d/secrets/orchestrator-encryption-keys.json',
105+
'/etc/puppetlabs/console-services/conf.d/secrets/keys.json',
106+
'/etc/puppetlabs/puppet/hiera.yaml'
107+
]
108+
parallelize($content_sources) |$path| {
109+
run_plan('peadm::util::copy_file', $replica_target,
110+
source_host => $primary_target,
111+
path => $path
112+
)
113+
}
105114

106115
# Provision the new system as a replica
107116
run_task('peadm::provision_replica', $primary_target,

plans/subplans/configure.pp

+17-17
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,23 @@
5858
$compiler_hosts,
5959
)
6060

61-
# Define the global hiera.yaml file on the Master; and syncronize to any Replica and Compilers.
62-
# This enables Data in the Classifier/Console, which is used/required by this architecture.
63-
# Necessary, for example, when promoting the Replica due to PE-18400 (and others).
64-
$global_hiera_yaml = run_task('peadm::read_file', $primary_target,
65-
path => '/etc/puppetlabs/puppet/hiera.yaml',
66-
).first['content']
67-
68-
run_task('peadm::mkdir_p_file', peadm::flatten_compact([
69-
$replica_target,
70-
$compiler_targets,
71-
]),
72-
path => '/etc/puppetlabs/puppet/hiera.yaml',
73-
owner => 'root',
74-
group => 'root',
75-
mode => '0644',
76-
content => $global_hiera_yaml,
77-
)
61+
# Source list of files on Primary and synchronize to new Replica
62+
$content_sources = [
63+
'/opt/puppetlabs/server/data/console-services/certs/ad_ca_chain.pem',
64+
'/etc/puppetlabs/orchestration-services/conf.d/secrets/keys.json',
65+
'/etc/puppetlabs/orchestration-services/conf.d/secrets/orchestrator-encryption-keys.json',
66+
'/etc/puppetlabs/console-services/conf.d/secrets/keys.json',
67+
'/etc/puppetlabs/puppet/hiera.yaml'
68+
]
69+
parallelize($content_sources) |$path| {
70+
run_plan('peadm::util::copy_file', peadm::flatten_compact([
71+
$replica_target,
72+
$compiler_targets,
73+
]),
74+
source_host => $primary_target,
75+
path => $path
76+
)
77+
}
7878

7979
# Set up the console node groups to configure the various hosts in their roles
8080

plans/util/copy_file.pp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# @api private
2+
plan peadm::util::copy_file(
3+
TargetSpec $targets,
4+
Peadm::SingleTargetSpec $source_host,
5+
Stdlib::Absolutepath $path
6+
) {
7+
8+
$source_target = peadm::get_targets($source_host, 1)
9+
$replica_target = $targets
10+
11+
$source_content = run_task('peadm::read_file', $source_target,
12+
path => $path
13+
).first['content']
14+
15+
if $source_content {
16+
run_task('peadm::mkdir_p_file', $replica_target,
17+
path => $path,
18+
owner => 'root',
19+
group => 'root',
20+
mode => '0644',
21+
content => $source_content,
22+
)
23+
} else {
24+
out::message("Skipping file copy: ${path} on ${source_target.peadm::certname()} had no content")
25+
}
26+
}

plans/util/sync_global_hiera.pp

-22
This file was deleted.

spec/plans/add_compiler_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def allow_standard_non_returning_calls
4949
# ["--puppet-service-ensure", "stopped",
5050
# "extension_requests:1.3.6.1.4.1.34380.1.3.13=pe_compiler", "extension_requests:1.3.6.1.4.1.34380.1.1.9813=A", "main:certname=compiler"], "server"=>"primary"}
5151

52-
expect_plan('peadm::util::sync_global_hiera').be_called_times(1)
52+
expect_plan('peadm::util::copy_file').be_called_times(1)
5353
expect(run_plan('peadm::add_compiler', params)).to be_ok
5454
end
5555

@@ -69,7 +69,7 @@ def allow_standard_non_returning_calls
6969
'--puppet-service-ensure', 'stopped',
7070
'main:certname=compiler'
7171
] })
72-
expect_plan('peadm::util::sync_global_hiera').be_called_times(1)
72+
expect_plan('peadm::util::copy_file').be_called_times(1)
7373
expect(run_plan('peadm::add_compiler', params2)).to be_ok
7474
end
7575
end

spec/plans/add_replica_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def allow_standard_non_returning_calls
4040
'--puppet-service-ensure', 'stopped',
4141
'main:certname=replica'
4242
] })
43-
expect_plan('peadm::util::sync_global_hiera')
43+
expect_plan('peadm::util::copy_file').be_called_times(5)
4444

4545
expect_out_verbose.with_params('Current config is...')
4646
expect_out_verbose.with_params('Updating classification to...')
@@ -60,7 +60,7 @@ def allow_standard_non_returning_calls
6060
'--puppet-service-ensure', 'stopped',
6161
'main:certname=replica'
6262
] })
63-
expect_plan('peadm::util::sync_global_hiera')
63+
expect_plan('peadm::util::copy_file').be_called_times(5)
6464

6565
expect_out_verbose.with_params('Current config is...')
6666
expect_out_verbose.with_params('Updating classification to...')

spec/plans/subplans/configure_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
allow_any_plan
1111
allow_any_command
1212

13-
expect_task('peadm::read_file').always_return({ 'content' => 'mock' })
13+
expect_task('peadm::util::copy_file').not_be_called
1414
expect_task('peadm::provision_replica').not_be_called
1515
expect_task('peadm::code_manager').not_be_called
1616

0 commit comments

Comments
 (0)