|
9 | 9 | # over to the masters at /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa
|
10 | 10 | # If the file does not exist the value will simply be supplied to the masters
|
11 | 11 | #
|
| 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 | +# |
12 | 17 | # @param pe_conf_data
|
13 | 18 | # Config data to plane into pe.conf when generated on all hosts, this can be
|
14 | 19 | # used for tuning data etc.
|
|
36 | 41 | Optional[String] $r10k_private_key_file = undef,
|
37 | 42 | Optional[Peadm::Pem] $r10k_private_key_content = undef,
|
38 | 43 |
|
| 44 | + # License key |
| 45 | + Optional[String] $license_key_file = undef, |
| 46 | + Optional[String] $license_key_content = undef, |
| 47 | + |
39 | 48 | # Other
|
40 | 49 | String $stagingdir = '/tmp',
|
41 | 50 | ) {
|
|
91 | 100 |
|
92 | 101 | $dns_alt_names_csv = $dns_alt_names.reduce |$csv,$x| { "${csv},${x}" }
|
93 | 102 |
|
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 |
95 | 104 | # appropriate value in $r10k_private_key. The value of this variable should
|
96 | 105 | # 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) |
108 | 110 |
|
109 | 111 | $precheck_results = run_task('peadm::precheck', $all_targets)
|
110 | 112 | $platform = $precheck_results.first['platform'] # Assume the platform of the first result correct
|
|
212 | 214 | }
|
213 | 215 |
|
214 | 216 | 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 | + ]), |
216 | 221 | path => '/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa',
|
217 | 222 | owner => 'pe-puppet',
|
218 | 223 | group => 'pe-puppet',
|
|
221 | 226 | )
|
222 | 227 | }
|
223 | 228 |
|
| 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 | +
|
224 | 242 | # Configure autosigning for the puppetdb database hosts 'cause they need it
|
225 | 243 | $autosign_conf = $database_targets.reduce('') |$memo,$target| { "${target.name}\n${memo}" }
|
226 | 244 | run_task('peadm::mkdir_p_file', $master_target,
|
|
0 commit comments