Skip to content

Commit

Permalink
(SUP-4402) pe_status_check fails if hiera.yaml is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyEwings committed Sep 4, 2023
1 parent 51643b8 commit 4659442
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/facter/pe_status_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,16 +387,22 @@

chunk(:S0033) do
next unless ['primary', 'legacy_primary', 'replica', 'pe_compiler', 'legacy_compiler'].include?(Facter.value('pe_status_check_role'))

hiera_config_path = Puppet.settings['hiera_config']
next unless File.exist?(hiera_config_path)
hiera_config_file = YAML.load_file(hiera_config_path)
hiera_version = hiera_config_file.dig('version')
if hiera_version.nil?
if File.exist?(hiera_config_path)
hiera_config_file = YAML.load_file(hiera_config_path)
else
{ S0033: false }
# Is Hiera 5 in use?
end

if hiera_config_file.is_a?(Hash) && !hiera_config_file.empty?
hiera_version = hiera_config_file.dig('version')
if hiera_version.nil?
{ S0033: false }
else
{ S0033: hiera_version.to_i == 5 }
end
else
{ S0033: hiera_version.to_i == 5 }
{ S0033: false }
end
end

Expand Down

0 comments on commit 4659442

Please sign in to comment.