lib/kafo/base_context.rb in kafo-4.0.1 vs lib/kafo/base_context.rb in kafo-4.1.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'open3' + module Kafo class BaseContext def facts self.class.facts end @@ -22,14 +24,20 @@ @facter_path = nil end def self.facts @facts ||= begin - symbolize(JSON.load(`#{facter_path} --json`) || {}) + result = run_command("#{facter_path} --json") + symbolize(JSON.load(result) || {}) end end def self.facter_path @facter_path ||= PuppetCommand.search_puppet_path('facter') + end + + def self.run_command(command) + stdout, _stderr, _status = Open3.capture3(*PuppetCommand.format_command(command)) + stdout end end end