Skip to content

Commit

Permalink
update fact_on() from facter to puppet facts
Browse files Browse the repository at this point in the history
Both tools support json output. For `puppet facts` it's even the
default. `puppet facts` is the successor of `facter`. Newer facts, like
`puppetversion` are not shown by `facter`, but `puppet facts`.
bastelfreak committed Dec 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b137621 commit 6156e1c
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/beaker_puppet_helpers/dsl.rb
Original file line number Diff line number Diff line change
@@ -205,13 +205,7 @@ def apply_manifest(manifest, opts = {}, &block)
def fact_on(host, name, opts = {})
raise(ArgumentError, "fact_on's `name` option must be a String. You provided a #{name.class}: '#{name}'") unless name.is_a?(String)

if opts.is_a?(Hash)
opts['json'] = nil
else
opts << ' --json'
end

result = on host, Beaker::Command.new('facter', [name], opts)
result = on host, Beaker::Command.new('puppet facts show', [name], opts)
if result.is_a?(Array)
result.map { |res| JSON.parse(res.stdout)[name] }
else

0 comments on commit 6156e1c

Please sign in to comment.