diff --git a/lib/facter/eypconf_generic_id.rb b/lib/facter/eypconf_generic_id.rb index 7b17528..d9941a2 100644 --- a/lib/facter/eypconf_generic_id.rb +++ b/lib/facter/eypconf_generic_id.rb @@ -1,37 +1,39 @@ -Dir.entries("/opt/eypconf/id").select {|f| !File.directory? f}.each do |i| +if File.exists?('/opt/eypconf/id') then + Dir.entries("/opt/eypconf/id").select {|f| !File.directory? f}.each do |i| - genetic_id = Facter::Util::Resolution.exec("bash -c 'cat /opt/eypconf/id/#{i}'").to_s + genetic_id = Facter::Util::Resolution.exec("bash -c 'cat /opt/eypconf/id/#{i}'").to_s - if i[0]=='.' - fact_name=i[1..-1] - else - fact_name=i - end - - unless genetic_id.nil? or genetic_id.empty? - Facter.add("eypconf_#{fact_name}") do - setcode do - genetic_id - end + if i[0]=='.' then + fact_name=i[1..-1] + else + fact_name=i end - Facter.add("eypconf_#{fact_name}_uppercase") do - setcode do - genetic_id.upcase - end - end + unless genetic_id.nil? or genetic_id.empty? + Facter.add("eypconf_#{fact_name}") do + setcode do + genetic_id + end + end - Facter.add("eypconf_#{fact_name}_lowercase") do - setcode do - genetic_id.downcase - end - end + Facter.add("eypconf_#{fact_name}_uppercase") do + setcode do + genetic_id.upcase + end + end - Facter.add("eypconf_#{fact_name}_source") do - setcode do - i - end + Facter.add("eypconf_#{fact_name}_lowercase") do + setcode do + genetic_id.downcase + end + end + + Facter.add("eypconf_#{fact_name}_source") do + setcode do + i + end + end end - end + end end