Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a certbot_version fact #322

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

martijndegouw
Copy link
Contributor

This Pull Request (PR) adds the certbot version as a fact.

This fact can be used to add support for new certbot features while maintaining compatibility with older version.
Note that it does not take a custom $package_command into account.

@martijndegouw martijndegouw force-pushed the feature/certbotversion branch from b9ca07d to 33e65ef Compare June 30, 2023 10:20
# frozen_string_literal: true

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should confine on Facter::Util::Resolution.which('certbot') and not on the kernel I think?

Copy link
Contributor Author

@martijndegouw martijndegouw Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I copied that over from letsencrypt_directory.rb, assuming it would limit the fact to the supported operation systems only.

value = nil
certbot = Facter::Util::Resolution.which('certbot')
if certbot
output = Facter::Util::Resolution.exec("#{certbot} --version 2>/dev/null")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks, I always mix those two up.

@martijndegouw martijndegouw force-pushed the feature/certbotversion branch 2 times, most recently from 3cd3e05 to 169738a Compare June 30, 2023 13:09
Copy link
Member

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I would just reword a bit the fact description (see in-line comment: "default" vs "current").


setcode do
output = Facter::Core::Execution.execute('certbot --version 2>/dev/null')
output[%r{^certbot (.*)$}, 1] if output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL this syntax.

README.md Outdated Show resolved Hide resolved
@martijndegouw martijndegouw force-pushed the feature/certbotversion branch from 169738a to daa8363 Compare June 30, 2023 19:31
@smortex smortex changed the title feat(facts): add fact about certbot version Add a certbot_version fact Jun 30, 2023
@smortex smortex merged commit c125cb8 into voxpupuli:master Jun 30, 2023
@evgeni evgeni added the enhancement New feature or request label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants