Skip to content

Commit 77ad68d

Browse files
authored
Merge pull request #8524 from ciprianbadescu/maint/facts-diff-quickfix
(PUP-10940) use `puppet facts show` command to compare facts
2 parents dd0c7e5 + b7d8822 commit 77ad68d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/puppet/face/facts.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,18 @@
132132
Puppet::Node::Facts.indirection.terminus_class = :facter
133133

134134
if Puppet::Util::Package.versioncmp(Facter.value('facterversion'), '4.0.0') < 0
135-
facter3_result = Puppet::Node::Facts.indirection.find(Puppet.settings[:certname])
135+
cmd_flags = '--render-as json --show-legacy'
136136

137137
# puppet/ruby are in PATH since it was updated in the wrapper script
138-
puppet_cmd = 'puppet facts show --facterng --render-as json'
138+
puppet_show_cmd = "puppet facts show"
139139
if Puppet::Util::Platform.windows?
140-
puppet_cmd = "ruby -S -- puppet facts show --render-as json"
140+
puppet_show_cmd = "ruby -S -- #{puppet_show_cmd}"
141141
end
142-
facter4_result = Puppet::Util::Execution.execute(puppet_cmd)
143142

144-
fact_diff = FactDif.new(facter3_result.to_json, facter4_result, EXCLUDE_LIST)
143+
facter_3_result = Puppet::Util::Execution.execute("#{puppet_show_cmd} --no-facterng #{cmd_flags}")
144+
facter_ng_result = Puppet::Util::Execution.execute("#{puppet_show_cmd} --facterng #{cmd_flags}")
145+
146+
fact_diff = FactDif.new(facter_3_result, facter_ng_result, EXCLUDE_LIST)
145147
fact_diff.difs
146148
else
147149
Puppet.warning _("Already using Facter 4. To use `puppet facts diff` remove facterng from the .conf file or run `puppet config set facterng false`.")

lib/puppet/util/fact_dif.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
class FactDif
44
def initialize(old_output, new_output, exclude_list = [])
5-
@c_facter = JSON.parse(old_output)['values']
6-
@next_facter = JSON.parse(new_output)['values']
5+
@c_facter = JSON.parse(old_output)
6+
@next_facter = JSON.parse(new_output)
77
@exclude_list = exclude_list
88
@diff = {}
99
end

0 commit comments

Comments
 (0)