From 6156e1cc97d1b2e8e5970a55633aac5f9d48fc39 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Wed, 11 Dec 2024 17:34:17 +0100 Subject: [PATCH] update fact_on() from `facter` to `puppet facts` 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`. --- lib/beaker_puppet_helpers/dsl.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/beaker_puppet_helpers/dsl.rb b/lib/beaker_puppet_helpers/dsl.rb index ab28b22..a299694 100644 --- a/lib/beaker_puppet_helpers/dsl.rb +++ b/lib/beaker_puppet_helpers/dsl.rb @@ -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