feat: add incus module (#230)
- add a basic incus module Reviewed-on: https://git.query.consul/unkinben/puppet-prod/pulls/230
This commit was merged in pull request #230.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'yaml'
|
||||
|
||||
Facter.add(:incus) do
|
||||
setcode do
|
||||
# Check if the 'incus' executable exists
|
||||
incus_path = Facter::Util::Resolution.which('incus')
|
||||
next {} unless incus_path # Return an empty fact if incus isn't found
|
||||
|
||||
# Run the `incus info` command using the found path
|
||||
incus_output = Facter::Core::Execution.execute("#{incus_path} info")
|
||||
next {} if incus_output.empty? # Return an empty fact if there's no output
|
||||
|
||||
# Parse the output as YAML and return it
|
||||
YAML.safe_load(incus_output)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user