From daa8363066c42c5d3a76e8573719ae394f271ffc Mon Sep 17 00:00:00 2001 From: Martijn de Gouw Date: Fri, 30 Jun 2023 12:08:10 +0200 Subject: [PATCH] feat(facts): add fact about certbot version --- README.md | 9 +++++++++ lib/facter/certbot_version.rb | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 lib/facter/certbot_version.rb diff --git a/README.md b/README.md index 41396f84..ff623d0e 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,15 @@ letsencrypt::renew_deploy_hook_commands: ## Facts +* [certbot_version](#fact-certbotversion) +* [letsencrypt_directory](#fact-letsencryptdirectory) + +### Fact: certbot_version + +A fact that contains the current version of certbot installed on 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. ``` diff --git a/lib/facter/certbot_version.rb b/lib/facter/certbot_version.rb new file mode 100644 index 00000000..2a0ee3e8 --- /dev/null +++ b/lib/facter/certbot_version.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +Facter.add(:certbot_version) do + confine { Facter::Core::Execution.which('certbot') } + + setcode do + output = Facter::Core::Execution.execute('certbot --version 2>/dev/null') + output[%r{^certbot (.*)$}, 1] if output + end +end