Skip to content

Commit

Permalink
feat(facts): add fact about certbot version
Browse files Browse the repository at this point in the history
  • Loading branch information
martijndegouw committed Jun 30, 2023
1 parent 2dcc8a7 commit b9ca07d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ letsencrypt::renew_deploy_hook_commands:

## Facts

* [certbot_version](#fact-certbotversion)
* [letsencrypt_directory](#fact-letsencryptdirectory)

### Fact: certbot_version

A Facter fact that can be used to determine what the default version of certbot is for your operating system/distribution.

### Fact: letsencrypt_directory

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.

```
Expand Down
17 changes: 17 additions & 0 deletions lib/facter/certbot_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

Facter.add(:certbot_version) do
confine kernel: %w[FreeBSD Linux OpenBSD]

setcode do
value = nil
certbot = Facter::Util::Resolution.which('certbot')
if certbot
output = Facter::Util::Resolution.exec("#{certbot} --version 2>/dev/null")
unless output.nil?
value = output[%r{^certbot (.*)$}, 1]
end
end
value
end
end

0 comments on commit b9ca07d

Please sign in to comment.