Skip to content

Commit f14985e

Browse files
authored
Add puppet8 certificate renewal endpoint
From https://www.puppet.com/docs/puppet/8/server/http_certificate_renew
1 parent 2874863 commit f14985e

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

manifests/init.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@
539539
# $server_ca_enable_infra_crl:: Enable the separate CRL for Puppet infrastructure nodes
540540
# Defaults to false
541541
#
542+
# $server_ca_allow_auto_renewal:: Enable the auto renewal for client certificates
543+
# Defaults to false
544+
#
545+
# $server_ca_allow_auto_renewal_cert_ttl:: Set the auto renewal interval for client certificates
546+
# Defaults to 60d
547+
#
542548
# $server_max_open_files:: Increase the max open files limit for Puppetserver.
543549
# Defaults to undef
544550
#
@@ -748,6 +754,8 @@
748754
Boolean $server_ca_allow_sans = $puppet::params::server_ca_allow_sans,
749755
Boolean $server_ca_allow_auth_extensions = $puppet::params::server_ca_allow_auth_extensions,
750756
Boolean $server_ca_enable_infra_crl = $puppet::params::server_ca_enable_infra_crl,
757+
Boolean $server_ca_allow_auto_renewal = $puppet::params::server_ca_allow_auto_renewal,
758+
String $server_ca_allow_auto_renewal_cert_ttl = $puppet::params::server_ca_allow_auto_renewal_cert_ttl,
751759
Optional[Integer[1]] $server_max_open_files = $puppet::params::server_max_open_files,
752760
Optional[Stdlib::Absolutepath] $server_versioned_code_id = undef,
753761
Optional[Stdlib::Absolutepath] $server_versioned_code_content = undef,

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@
406406
$server_ca_allow_sans = false
407407
$server_ca_allow_auth_extensions = false
408408
$server_ca_enable_infra_crl = false
409+
$server_ca_allow_auto_renewal = false
410+
$server_ca_allow_auto_renewal_cert_ttl = '60d'
409411
$server_max_open_files = undef
410412
$server_environment_vars = {}
411413

manifests/server.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@
302302
#
303303
# $ca_enable_infra_crl:: Enable the separate CRL for Puppet infrastructure nodes
304304
# Defaults to false
305+
# $server_ca_allow_auto_renewal:: Enable the auto renewal for client certificates
306+
# Defaults to false
307+
#
308+
# $server_ca_allow_auto_renewal_cert_ttl:: Set the auto renewal interval for client certificates
309+
# Defaults to 60d
305310
#
306311
# $acceptor_threads:: This sets the number of threads that the webserver will dedicate to accepting
307312
# socket connections for unencrypted HTTP traffic. If not provided, the webserver
@@ -454,6 +459,8 @@
454459
Boolean $ca_allow_sans = $puppet::server_ca_allow_sans,
455460
Boolean $ca_allow_auth_extensions = $puppet::server_ca_allow_auth_extensions,
456461
Boolean $ca_enable_infra_crl = $puppet::server_ca_enable_infra_crl,
462+
Boolean $server_ca_allow_auto_renewal = $puppet::server_ca_allow_auto_renewal,
463+
String $server_ca_allow_auto_renewal_cert_ttl = $puppet::server_ca_allow_auto_renewal_cert_ttl,
457464
Optional[Integer[1]] $max_open_files = $puppet::server_max_open_files,
458465
Optional[Stdlib::Absolutepath] $versioned_code_id = $puppet::server_versioned_code_id,
459466
Optional[Stdlib::Absolutepath] $versioned_code_content = $puppet::server_versioned_code_content,

manifests/server/puppetserver.pp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
# }
7474
#
7575
class puppet::server::puppetserver (
76+
Optional[Pattern[/^[\d]\.[\d]+\.[\d]+$/]] $puppetserver_version = $puppet::server::puppetserver_version,
7677
String $config = $puppet::server::jvm_config,
7778
String $java_bin = $puppet::server::jvm_java_bin,
7879
Variant[String, Array[String]] $jvm_extra_args = $puppet::server::real_jvm_extra_args,
@@ -139,6 +140,8 @@
139140
Boolean $ca_allow_sans = $puppet::server::ca_allow_sans,
140141
Boolean $ca_allow_auth_extensions = $puppet::server::ca_allow_auth_extensions,
141142
Boolean $ca_enable_infra_crl = $puppet::server::ca_enable_infra_crl,
143+
Boolean $server_ca_allow_auto_renewal = $puppet::server::server_ca_allow_auto_renewal,
144+
String $server_ca_allow_auto_renewal_cert_ttl = $puppet::server::server_ca_allow_auto_renewal_cert_ttl,
142145
Optional[Integer[1]] $max_open_files = $puppet::server::max_open_files,
143146
Optional[Stdlib::Absolutepath] $versioned_code_id = $puppet::server::versioned_code_id,
144147
Optional[Stdlib::Absolutepath] $versioned_code_content = $puppet::server::versioned_code_content,
@@ -147,6 +150,17 @@
147150
) {
148151
include puppet::server
149152

153+
# For Puppetserver, certain configuration parameters are version specific.
154+
# We need a method to determine what version is installed.
155+
if $puppetserver_version {
156+
$real_puppetserver_version = $puppetserver_version
157+
} elsif versioncmp($facts['puppetversion'], '8.0.0') >= 0 {
158+
$real_puppetserver_version = '8.0.0'
159+
} else {
160+
# our minimum supported version of puppet server
161+
$real_puppetserver_version = '7.0.0'
162+
}
163+
150164
$puppetserver_package = pick($puppet::server::package, 'puppetserver')
151165

152166
$jvm_heap_arr = ["-Xms${jvm_min_heap_size}", "-Xmx${jvm_max_heap_size}"]

templates/server/puppetserver/conf.d/auth.conf.erb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ authorization: {
7777
name: "puppetlabs csr"
7878
},
7979
<%- if @server_ca -%>
80+
<%- if scope.function_versioncmp([@real_puppetserver_version, '8.0.0']) >= 0 -%>
81+
{
82+
# Allow nodes to renew their certificate
83+
match-request: {
84+
path: "/puppet-ca/v1/certificate_renewal"
85+
type: path
86+
method: post
87+
}
88+
# this endpoint should never be unauthenticated, as it requires the cert to be provided.
89+
allow: "*"
90+
sort-order: 500
91+
name: "puppetlabs certificate renewal"
92+
},
93+
<%- end -%>
8094
{
8195
# Allow the CA CLI to access the certificate_status endpoint
8296
match-request: {

templates/server/puppetserver/conf.d/ca.conf.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ certificate-authority: {
77

88
# enable the separate CRL for Puppet infrastructure nodes
99
enable-infra-crl: <%= @ca_enable_infra_crl %>
10+
11+
# Setup auto renewal of certs
12+
allow-auto-renewal: <%= @server_ca_allow_auto_renewal %>
13+
# This value determines the lifetime of the cert if auto-renewal is enabled
14+
auto-renewal-cert-ttl: <%= @server_ca_allow_auto_renewal_cert_ttl %>
15+
# Default cert expiration time. If the value is set here, it will take precedence over ca-ttl setting in puppet.conf
16+
#ca-ttl: "60d"
1017
}

0 commit comments

Comments
 (0)