Fix retrieval of hostname fact based on network.
authorSofer Athlan-Guyot <sathlang@redhat.com>
Wed, 22 Jun 2016 10:23:10 +0000 (12:23 +0200)
committerAthlan-Guyot sofer <sathlang@redhat.com>
Mon, 11 Jul 2016 09:25:37 +0000 (09:25 +0000)
When Facter.value(:domain) is nil the facts fqdn_<network> are failing
with :

Could not retrieve fact='fqdn_external', resolution='<anonymous>': undefined method `empty?' for nil:NilClass

Change-Id: I3e7fa983d4cf91c6ab25f9aa4c353b364f44826e
Closes-bug: 1595125

lib/facter/alt_fqdns.rb

index 24d6ef1..8a4d59b 100644 (file)
@@ -26,7 +26,7 @@
         Facter.value(:hostname),
         network,
         Facter.value(:domain),
-      ].reject { |part| part.empty? }
+      ].reject { |part| part.nil? || part.empty? }
       external_hostname_parts.join(".")
     end
   end