From fc9331a9b5feef11d68dff3813977b2533995f2f Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 14 Sep 2006 21:37:03 +0000 Subject: Fixing #20. I just made sure that the Domain fact cchecks the hostname first, so that if the hostname is an fqdn it will set the domain from that. git-svn-id: http://reductivelabs.com/svn/facter/trunk@165 1f5c1d6a-bddf-0310-8f58-fc49e503516a --- lib/facter.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/facter.rb b/lib/facter.rb index d81c61c..f799783 100644 --- a/lib/facter.rb +++ b/lib/facter.rb @@ -691,6 +691,10 @@ class Facter Facter.add("Domain") do setcode do + # First force the hostname to be checked + Facter.hostname + + # Now check to see if it set the domain if defined? $domain and ! $domain.nil? $domain else @@ -775,7 +779,7 @@ class Facter require 'resolv' begin - if hostname = Facter["hostname"].value + if hostname = Facter.hostname ip = Resolv.getaddress(hostname) unless ip == "127.0.0.1" ip @@ -792,9 +796,10 @@ class Facter end Facter.add("IPAddress") do setcode do - if hostname = Facter["hostname"].value + if hostname = Facter.hostname # we need Hostname to exist for this to work - if list = Resolution.exec("host #{hostname}").chomp.split(/\s/) + host = nil + if host = Resolution.exec("host #{hostname}") and host.chomp.split(/\s/) if defined? list[-1] and list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ -- cgit