File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,27 @@ letsencrypt::renew_deploy_hook_commands:
347347 - '...'
348348` ` `
349349
350+ # # Facts
351+
352+ Facts about your live certificates are available through facter. You can query the list of live certificates from puppet using `$::letsencrypt_directory` in your puppet code, hiera data or from the command line.
353+
354+ ```
355+ facter -p letsencrypt_directory
356+ {
357+ legacyfiles.ijc.org => "/etc/letsencrypt/live/legacyfiles.ijc.org",
358+ static.ijc.org => "/etc/letsencrypt/live/static.ijc.org",
359+ ijc.org => "/etc/letsencrypt/live/ijc.org",
360+ new.ijc.org => "/etc/letsencrypt/live/new.ijc.org",
361+ www.ijc.org => "/etc/letsencrypt/live/ijc.org",
362+ training.ijc.org => "/etc/letsencrypt/live/training.ijc.org"
363+ }
364+ ```
365+
366+ ## Puppet Functions
367+
368+ This module profiles a custom puppet function `letsencrypt_lookup` which allows you to load information about your certificates into puppet.
369+ This returns the same information as in the facts but for a particular domain. It accepts a single argument for your domain or wildcard domain.
370+
350371## Development
351372
3523731. Fork it
Original file line number Diff line number Diff line change 1+ require 'openssl'
2+ require 'pathname'
3+
4+ Facter . add ( :letsencrypt_directory ) do
5+ confine kernel : %w[ FreeBSD Linux OpenBSD ]
6+
7+ setcode do
8+ certs = { }
9+
10+ # locate the certificate repository
11+ livedir = [ '/etc/letsencrypt/live' , '/etc/certbot/live' ] .
12+ map { |path | Pathname . new path } .
13+ find ( &:directory? )
14+
15+ unless livedir . nil?
16+ Pathname . new ( livedir ) . children . select ( &:directory? ) . each do |path |
17+ pem = File . join ( path , 'cert.pem' )
18+ cert = OpenSSL ::X509 ::Certificate . new ( File . new ( pem ) . read )
19+ san = cert . extensions . find { |e | e . oid == 'subjectAltName' }
20+ names = san . value . split ( ',' ) . map { |entry | entry . split ( ':' ) [ 1 ] }
21+ names . each do |n |
22+ certs [ n ] = path . to_s
23+ end
24+ end
25+ end
26+
27+ certs
28+ end
29+ end
Original file line number Diff line number Diff line change 1+ Puppet ::Functions . create_function ( :letsencrypt_lookup ) do
2+ def letsencrypt_lookup ( cn )
3+ domain = cn . split ( '.' , 2 ) [ 1 ]
4+ wildcard = "*.#{ domain } "
5+ certs = closure_scope [ 'facts' ] . fetch ( 'letsencrypt_directory' , nil )
6+ certs . fetch ( cn , certs . fetch ( wildcard , nil ) ) unless certs . nil?
7+ end
8+ end
You can’t perform that action at this time.
0 commit comments