Defined Type: dehydrated::certificate
- Defined in:
- manifests/certificate.pp
Summary
Creates key & csr and request the certificate.Overview
Triggers key and csr generation and requests the certificate via the host configured in $dehydrated_host. This is the main defined type to use if you want to have a certificate. Together with the defaults in the dehydrated class you should have everything to make requesting certificates possible. Especially the dehydrated::certificate::* types do not have a public API and can change without warning. Don't rely on them. Dehydrated::Certificate[$dn] is also what you want to use to subscribe to if you want to restart services after certificates have been installed/updated.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'manifests/certificate.pp', line 76
define dehydrated::certificate (
Dehydrated::DN $dn = $name,
String $base_filename = regsubst($dn, '^\*', '_wildcard_'),
Array[Dehydrated::DN] $subject_alternative_names = [],
Dehydrated::Challengetype $challengetype = $dehydrated::challengetype,
Dehydrated::Algorithm $algorithm = $dehydrated::algorithm,
Integer[768] $key_size = $dehydrated::key_size,
Integer[768] $dh_param_size = $dehydrated::dh_param_size,
Stdlib::Fqdn $dehydrated_host = $dehydrated::dehydrated_host,
Hash $dehydrated_environment = $dehydrated::dehydrated_environment,
Optional[Dehydrated::Hook] $dehydrated_hook = $dehydrated::dehydrated_hook,
String $letsencrypt_ca = $dehydrated::letsencrypt_ca,
Optional[Dehydrated::Hook] $dehydrated_domain_validation_hook = $dehydrated::dehydrated_domain_validation_hook,
Optional[String] $key_password = undef,
Optional[String] $preferred_chain = $dehydrated::preferred_chain,
) {
if ! defined(Class['dehydrated']) {
fail('You must include the dehydrated base class first.')
}
require dehydrated::setup
require dehydrated::params
# ensure $dn is also in subject_alternative_names
$_subject_alternative_names = unique(flatten([$dn, $subject_alternative_names]))
$domain_config = {
$dn => {
'subject_alternative_names' => $_subject_alternative_names,
'base_filename' => $base_filename,
'dh_param_size' => $dh_param_size,
'challengetype' => $challengetype,
'dehydrated_host' => $dehydrated_host,
'dehydrated_environment' => $dehydrated_environment,
'dehydrated_hook' => $dehydrated_hook,
'dehydrated_domain_validation_hook' => $dehydrated_domain_validation_hook,
'letsencrypt_ca' => $letsencrypt_ca,
'preferred_chain' => $preferred_chain,
},
}
$json_fragment = to_json($domain_config)
::concat::fragment { "${trusted['certname']}-${dn}" :
target => $dehydrated::params::domainfile,
content => $json_fragment,
order => '50',
}
dehydrated::certificate::csr { $base_filename :
dn => $dn,
subject_alternative_names => $subject_alternative_names,
key_password => $key_password,
algorithm => $algorithm,
size => $key_size,
}
$ready_for_merge = $dn in $dehydrated::ready_for_merge
if $ready_for_merge {
dehydrated::certificate::deploy { $dn :
key_password => $key_password,
}
}
}
|