Skip to content

Commit de93ec2

Browse files
committed
Convert two functions to plans
Really, they were already plans. This makes it obvious that they are when using them in other plans.
1 parent e9266f0 commit de93ec2

File tree

5 files changed

+50
-42
lines changed

5 files changed

+50
-42
lines changed

Diff for: functions/install_module.pp

-29
This file was deleted.

Diff for: plans/configure.pp

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@
3030

3131
# Retrieve and deploy Puppet modules from the Forge so that they can be used
3232
# for ensuring some configuration (node groups)
33-
pe_xl::install_module($master_target, 'WhatsARanjit-node_manager', '0.7.1', $stagingdir)
34-
pe_xl::install_module($master_target, 'puppetlabs-stdlib', '5.0.0', $stagingdir)
33+
[ ['WhatsARanjit-node_manager', '0.7.1'],
34+
['puppetlabs-stdlib', '5.0.0'],
35+
].each |$tuple| {
36+
run_plan('pe_xl::util::install_module',
37+
nodes => $master_target,
38+
module => $tuple[0],
39+
version => $tuple[1],
40+
stagingdir => $stagingdir,
41+
)
42+
}
3543

3644
# Set up the console node groups to configure the various hosts in their
3745
# roles

Diff for: plans/install.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@
8585
$local_tarball_path = "${stagingdir}/${pe_tarball_name}"
8686
$upload_tarball_path = "/tmp/${pe_tarball_name}"
8787

88-
pe_xl::retrieve_and_upload(
89-
"https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-el-7-x86_64.tar.gz",
90-
$local_tarball_path,
91-
$upload_tarball_path,
92-
[$master_host, $puppetdb_database_host, $puppetdb_database_replica_host]
88+
run_plan('pe_xl::util::retrieve_and_upload',
89+
nodes => [$master_host, $puppetdb_database_host, $puppetdb_database_replica_host],
90+
source => "https://s3.amazonaws.com/pe-builds/released/${version}/puppet-enterprise-${version}-el-7-x86_64.tar.gz",
91+
local_path => $local_tarball_path,
92+
upload_path => $upload_tarball_path,
9393
)
9494

9595
# Create csr_attributes.yaml files for the nodes that need them

Diff for: plans/util/install_module.pp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
plan pe_xl::util::install_module(
2+
TargetSpec $nodes,
3+
String[1] $module,
4+
String[1] $version,
5+
String[1] $stagingdir = '/tmp',
6+
) {
7+
8+
$module_tarball = "${module.regsubst('/', '-')}-${version}.tar.gz"
9+
10+
run_plan('pe_xl::util::retrieve_and_upload',
11+
nodes => $nodes,
12+
source => "https://forge.puppet.com/v3/files/${module_tarball}",
13+
local_path => "${stagingdir}/${module_tarball}",
14+
upload_path => "/tmp/${module_tarball}",
15+
)
16+
17+
run_command(@("HEREDOC"), $nodes)
18+
/opt/puppetlabs/bin/puppet module install \
19+
--modulepath /etc/puppetlabs/code-staging/environments/production/modules \
20+
--ignore-dependencies \
21+
/tmp/${module_tarball}
22+
| HEREDOC
23+
24+
run_command('chown -R pe-puppet:pe-puppet /etc/puppetlabs/code-staging', $nodes)
25+
run_task('pe_xl::code_manager', $nodes,
26+
action => 'commit',
27+
)
28+
29+
}

Diff for: functions/retrieve_and_upload.pp renamed to plans/util/retrieve_and_upload.pp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function pe_xl::retrieve_and_upload(
2-
$source,
3-
$local_path,
4-
$upload_path,
5-
$target,
1+
plan pe_xl::util::retrieve_and_upload(
2+
TargetSpec $nodes,
3+
String[1] $source,
4+
String[1] $local_path,
5+
String[1] $upload_path,
66
) {
77
$exists = without_default_logging() || {
88
run_command("test -e '${local_path}'", 'local://localhost',
@@ -21,7 +21,7 @@ function pe_xl::retrieve_and_upload(
2121
path => $local_path,
2222
).first['size']
2323

24-
$targets_needing_file = run_task('pe_xl::filesize', $target,
24+
$targets_needing_file = run_task('pe_xl::filesize', $nodes,
2525
path => $upload_path,
2626
).filter |$result| {
2727
$result['size'] != $local_size

0 commit comments

Comments
 (0)