Skip to content

Commit 31bca72

Browse files
committed
Manage license file
This commit allows you to manage the license key file associated with PE. This file is managed in the same way the r10k private key file is currently managed in this tool per the request of @reidmv
1 parent f38dc18 commit 31bca72

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

plans/action/install.pp

+31
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
# over to the masters at /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa
1010
# If the file does not exist the value will simply be supplied to the masters
1111
#
12+
# @param license_key
13+
# The license key to use with Puppet Enterprise. If this is a local file it
14+
# will be copied over to the MoM at /etc/puppetlabs/license.key
15+
# If the file does not exist the value will simply be supplied to the masters
16+
#
1217
# @param pe_conf_data
1318
# Config data to plane into pe.conf when generated on all hosts, this can be
1419
# used for tuning data etc.
@@ -36,6 +41,10 @@
3641
Optional[String] $r10k_private_key_file = undef,
3742
Optional[Peadm::Pem] $r10k_private_key_content = undef,
3843

44+
# License key
45+
Optional[String] $license_key_file = undef,
46+
Optional[String] $license_key_content = undef,
47+
3948
# Other
4049
String $stagingdir = '/tmp',
4150
) {
@@ -106,6 +115,18 @@
106115
},
107116
}
108117

118+
$license_key = [
119+
$license_key_file,
120+
$license_key_content,
121+
].peadm::flatten_compact.size ? {
122+
0 => undef, # no key data supplied
123+
2 => fail('Must specify either one or neither of license_key_file and license_key_content; not both'),
124+
1 => $license_key_file ? {
125+
String => file($license_key_file), # key file path supplied, read data from file
126+
undef => $license_key_content, # key content supplied directly, use as-is
127+
},
128+
}
129+
109130
$precheck_results = run_task('peadm::precheck', $all_targets)
110131
$platform = $precheck_results.first['platform'] # Assume the platform of the first result correct
111132

@@ -221,6 +242,16 @@
221242
)
222243
}
223244
245+
if $license_key {
246+
run_task('peadm::mkdir_p_file', [$master_target, $master_replica_target],
247+
path => '/etc/puppetlabs/license.key',
248+
owner => 'pe-puppet',
249+
group => 'pe-puppet',
250+
mode => '0400',
251+
content => $license_key,
252+
)
253+
}
254+
224255
# Configure autosigning for the puppetdb database hosts 'cause they need it
225256
$autosign_conf = $database_targets.reduce('') |$memo,$target| { "${target.name}\n${memo}" }
226257
run_task('peadm::mkdir_p_file', $master_target,

plans/provision.pp

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
Optional[Peadm::Pem] $r10k_private_key_content = undef,
2828
Optional[String] $deploy_environment = undef,
2929

30+
# License Key
31+
Optional[String] $license_key_file = undef,
32+
Optional[String] $license_key_content = undef,
33+
3034
# Other
3135
Optional[String] $stagingdir = undef,
3236
) {
@@ -54,6 +58,10 @@
5458
r10k_private_key_file => $r10k_private_key_file,
5559
r10k_private_key_content => $r10k_private_key_content,
5660

61+
# License Key
62+
license_key_file => $license_key_file,
63+
license_key_content => $license_key_content,
64+
5765
# Other
5866
stagingdir => $stagingdir,
5967
)
@@ -81,3 +89,4 @@
8189
# Return a string banner reporting on what was done
8290
return([$install_result, $configure_result])
8391
}
92+

0 commit comments

Comments
 (0)