Skip to content

Commit 0438075

Browse files
committed
Re-use sync_global_hiera plan
Modifies the peadm::util::sync_global_hera plan so that it can handle the copying of many files from a source to a group of targets. Renames the plan to peadm::util::copy_file
1 parent 21736d1 commit 0438075

File tree

5 files changed

+55
-46
lines changed

5 files changed

+55
-46
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

+15-5
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,21 @@
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/puuppetlabs/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+
_catch_errors => true
113+
)
114+
}
105115

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

plans/subplans/configure.pp

+15-17
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,21 @@
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/puuppetlabs/puppet/hiera.yaml'
68+
]
69+
parallelize($content_sources) |$path| {
70+
run_plan('peadm::util::copy_file', $replica_target,
71+
source_host => $primary_target,
72+
path => $path,
73+
_catch_errors => true
74+
)
75+
}
7876

7977
# Set up the console node groups to configure the various hosts in their roles
8078

plans/util/copy_file.pp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# @api private
2+
plan peadm::util::copy_file(
3+
Peadm::SingleTargetSpec $targets,
4+
Peadm::SingleTargetSpec $source_host,
5+
String[1] $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+
run_task('peadm::mkdir_p_file', $replica_target,
16+
path => $path,
17+
owner => 'root',
18+
group => 'root',
19+
mode => '0644',
20+
content => $source_content,
21+
)
22+
}

plans/util/sync_global_hiera.pp

-22
This file was deleted.

0 commit comments

Comments
 (0)