Puppet Plan: cd4peadm::install::configure_ssl_termination
- Defined in:
- plans/install/configure_ssl_termination.pp
Overview
Checks if the user has specified certs, key, and CRL for use by nginx for SSL termination. If no certs were provided, generates a key, self-signed cert, and CRL. In either case, uploads the artifacts to the location expected by the nginx container.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'plans/install/configure_ssl_termination.pp', line 11
plan cd4peadm::install::configure_ssl_termination(
Cd4peadm::Config $config,
) {
# For now, assume that there is only one target associated with the UI role
# Other parts of this plan, notably the `generate` function, will need
# updating if this changes.
$ui_host = $config['roles']['ui']['targets'][0]
$upload_dir = '/etc/puppetlabs/cd4pe/browser_certs'
$cert_chain = $config['ssl']['cert_chain']
$private_key = $config['ssl']['private_key']
$crl = $config['ssl']['crl']
out::message('Validating certificate from Hiera data.')
$valid = cd4peadm::verify_certs($cert_chain, $private_key.unwrap)
if $valid {
out::message('Valid browser certificates found.')
} else {
fail_plan('Invalid browser certificates or key provided. Aborting.', 'cd4pe/error')
}
run_command("mkdir -p ${upload_dir}", $ui_host, { '_run_as' => 'root' })
out::message('Uploading browser certficate chain.')
write_file($cert_chain, "${upload_dir}/cert_chain.pem", $ui_host, { '_run_as' => 'root' })
out::message('Uploading browser private key.')
write_file($private_key.unwrap, "${upload_dir}/private_key.pem", $ui_host, { '_run_as' => 'root' })
run_command("chmod 0400 ${upload_dir}/private_key.pem", $ui_host, { '_run_as' => 'root' })
out::message('Uploading browser crl.')
write_file($crl, "${upload_dir}/crl.pem", $ui_host, { '_run_as' => 'root' })
out::message('Uploading certificates for job hardware.')
write_file($cert_chain, '/etc/puppetlabs/cd4pe/job-certs.pem',
$config['roles']['backend']['targets'], { '_run_as' => 'root' }
)
}
|