summaryrefslogtreecommitdiffstats
path: root/lib/facter.rb
diff options
context:
space:
mode:
authorluke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a>2006-09-14 21:37:03 +0000
committerluke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a>2006-09-14 21:37:03 +0000
commitfc9331a9b5feef11d68dff3813977b2533995f2f (patch)
treedd34c61f8a98b241feaebe926bf2433c8701986b /lib/facter.rb
parent07a42e66a26c30f06b01dec5e568668ea715095b (diff)
downloadfacter-fc9331a9b5feef11d68dff3813977b2533995f2f.tar.gz
facter-fc9331a9b5feef11d68dff3813977b2533995f2f.tar.xz
facter-fc9331a9b5feef11d68dff3813977b2533995f2f.zip
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
Diffstat (limited to 'lib/facter.rb')
-rw-r--r--lib/facter.rb11
1 files changed, 8 insertions, 3 deletions
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]+/