Skip to content

Commit 83eb2c1

Browse files
authored
Merge pull request #61 from abrader/serveng-24-license-file
Manage license file
2 parents 97c82eb + b81d45c commit 83eb2c1

File tree

3 files changed

+59
-13
lines changed

3 files changed

+59
-13
lines changed

functions/file_or_content.pp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function peadm::file_or_content(
2+
String $param_name,
3+
String $file,
4+
String $content,
5+
) {
6+
7+
$value = [
8+
$file,
9+
$content,
10+
].peadm::flatten_compact.size ? {
11+
0 => undef, # no key data supplied
12+
2 => fail("Must specify either one or neither of ${param_name}_file and ${param_name}_content; not both"),
13+
1 => $file ? {
14+
String => file($file), # file path supplied, read data from file
15+
undef => $content, # content supplied directly, use as-is
16+
},
17+
}
18+
19+
}

plans/action/install.pp

+31-13
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
) {
@@ -91,20 +100,13 @@
91100

92101
$dns_alt_names_csv = $dns_alt_names.reduce |$csv,$x| { "${csv},${x}" }
93102

94-
# Process user input for r10k private key (content or file) and set
103+
# Process user input for r10k private key (file or content) and set
95104
# appropriate value in $r10k_private_key. The value of this variable should
96105
# either be undef or else the key content to write.
97-
$r10k_private_key = [
98-
$r10k_private_key_file,
99-
$r10k_private_key_content,
100-
].peadm::flatten_compact.size ? {
101-
0 => undef, # no key data supplied
102-
2 => fail('Must specify either one or neither of r10k_private_key_file and r10k_private_key_content; not both'),
103-
1 => $r10k_private_key_file ? {
104-
String => file($r10k_private_key_file), # key file path supplied, read data from file
105-
undef => $r10k_private_key_content, # key content supplied directly, use as-is
106-
},
107-
}
106+
$r10k_private_key = peadm::file_or_content('r10k_private_key', $r10k_private_key_file, $r10k_private_key_content)
107+
108+
# Same for license key
109+
$license_key = peadm::file_or_content('license_key', $license_key_file, $license_key_content)
108110

109111
$precheck_results = run_task('peadm::precheck', $all_targets)
110112
$platform = $precheck_results.first['platform'] # Assume the platform of the first result correct
@@ -212,7 +214,10 @@
212214
}
213215
214216
if $r10k_private_key {
215-
run_task('peadm::mkdir_p_file', [$master_target, $master_replica_target],
217+
run_task('peadm::mkdir_p_file', peadm::flatten_compact([
218+
$master_target,
219+
$master_replica_target,
220+
]),
216221
path => '/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa',
217222
owner => 'pe-puppet',
218223
group => 'pe-puppet',
@@ -221,6 +226,19 @@
221226
)
222227
}
223228
229+
if $license_key {
230+
run_task('peadm::mkdir_p_file', peadm::flatten_compact([
231+
$master_target,
232+
$master_replica_target,
233+
]),
234+
path => '/etc/puppetlabs/license.key',
235+
owner => 'pe-puppet',
236+
group => 'pe-puppet',
237+
mode => '0400',
238+
content => $license_key,
239+
)
240+
}
241+
224242
# Configure autosigning for the puppetdb database hosts 'cause they need it
225243
$autosign_conf = $database_targets.reduce('') |$memo,$target| { "${target.name}\n${memo}" }
226244
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)