Forge Home

puppet_certificate

Puppet provider ensuring puppet certificates

1,844 downloads

512 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.1.0 (latest)
  • 1.0.0
released Feb 1st 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
  • Puppet >= 7.0.0 < 9.0.0
  • RedHat, Windows, Debian, Ubuntu, OS X, Solaris, SLES, AIX

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'puppet-puppet_certificate', '1.1.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add puppet-puppet_certificate
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install puppet-puppet_certificate --version 1.1.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

puppet/puppet_certificate — version 1.1.0 Feb 1st 2024

Puppet Certificate

Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores Apache-2 License Donated by Reid Vandewiele

Summary

Manage Puppet certificates as resources using the puppet_certificate type.

Usage

Example:

puppet_certificate { 'puppetmaster07.example.com':
  ensure        => present,
  dns_alt_names => [
    'puppet',
    'puppet.example.com',
  ],
}

puppet_certificate { 'oldcert.example.com':
  ensure => absent,
}

Advanced features

Refresh

When refreshed (notify, subscribe) a puppet_certificate resource will destroy and re-create the managed certificate. This enables changes to related resources to trigger a certificate to be regenerated.

To enable this functionality, you must set the onrefresh parameter to regenerate. Otherwise, the resource will not respond to refresh events.

Note that for this to work as expected, it will need to be combined with automatic certificate cleaning (described in a following section).

file { '/etc/puppetlabs/puppet/csr_attributes.yaml':
  ensure  => file,
  owner   => 'root',
  group   => 'root',
  mode    => '0440',
  content => epp('example/csr_attributes.yaml.epp'),
}

~> puppet_certificate { $certname:
  ensure      => present,
  waitforcert => 60,
  onrefresh   => regenerate,
}

Ensure valid

Besides ensure=present, a puppet_certificate may be set to ensure=valid. When configured this way, if the Puppet certificate has expired, it will be destroyed and a new certificate created. Note that this does not automatically handle signing of the new certificate, or cleanup of the old (expired) certificate.

The renewal_grace_period parameter may be combined with ensure=valid to perform certificate regeneration a configurable number of days before a certificate is due to expire.

puppet_certificate { $certname:
  ensure               => valid,
  renewal_grace_period => 20,
}

Automatic certificate cleaning

The clean parameter tells a puppet_certificate to try and clean a certificate from the CA upon destroying it.

This is useful to keep the CA clean, and as a prerequisite action for generating a new certificate of the same name. To use this option effectively, it is required that a rule be added to auth.conf on the CA to allow this. For example, to allow nodes to revoke and clean their own certificates.

Example auth.conf rule:

{
    name: "Allow nodes to delete their own certificates",
    match-request: {
        path: "^/puppet-ca/v1/certificate(_status|_request)?/([^/]+)$",
        type: regex,
        method: [delete]
    },
    allow: "$2",
    sort-order: 500
}

Puppet Enterprise already has a rule for this API. You cannot have multiple blocks in auth.conf for the same path. Therefore you need to patch /opt/puppetlabs/puppet/modules/puppet_enterprise/manifests/profile/certificate_authority.pp

# git diff --no-index /tmp/certificate_authority.pp
/opt/puppetlabs/puppet/modules/puppet_enterprise/manifests/profile/certificate_authority.pp
diff --git a/tmp/certificate_authority.pp
b/opt/puppetlabs/puppet/modules/puppet_enterprise/manifests/profile/certificate_authority.pp
index ba4de6b..4c71dd5 100644
--- a/tmp/certificate_authority.pp
+++ b/opt/puppetlabs/puppet/modules/puppet_enterprise/manifests/profile/certificate_authority.pp
@@ -99,10 +99,10 @@ class puppet_enterprise::profile::certificate_authority (

   pe_puppet_authorization::rule { 'puppetlabs certificate status':
     ensure               => present,
-    match_request_path   => '/puppet-ca/v1/certificate_status/',
-    match_request_type   => 'path',
+    match_request_path   => '^/puppet-ca/v1/certificate_status/([^/]+)?$',
+    match_request_type   => 'regex',
     match_request_method => ['get','put','delete'],
-    allow                => $_client_allowlist << $ca_cli_extension,
+    allow                => ['$1', $_client_allowlist].flatten << $ca_cli_extension,
     sort_order           => 500,
     path                 => '/etc/puppetlabs/puppetserver/conf.d/auth.conf',
     notify               => Service['pe-puppetserver'],
puppet_certificate { $certname:
  ensure               => valid,
  waitforcert          => 60,
  renewal_grace_period => 20,
  clean                => true,
}

Reference

Contributors

  • Reid Vandewiele
  • Branan Riley
  • Raphaël Pinson

Transfer Notice

This module was originally authored by Reid Vandewiele. The maintainer preferred that Vox Pupuli take ownership of the module for future improvement and maintenance.

Existing pull requests and issues were transferred over. Please fork and continue to contribute here instead of the module's original home.