[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, master, updated. 3903f23539914468d02d22048eced68f6c830bdb

Stig Sandbeck Mathisen ssm at debian.org
Wed Jul 28 20:20:05 UTC 2010


The following commit has been merged in the master branch:
commit 34fe2c388bfd8eb13929660c1492fc62cd042996
Author: Ohad Levy <ohad.levy at infineon.com>
Date:   Mon Jan 18 10:42:43 2010 +0800

    fixes #2573, #2085, #1291 - fixes domain and fqdn facts resolution
    
    This patch removes the relationship between the domain fact and LDAP/NIS domains.
    domain fact relates to DNS domain - this will avoid the confusion caused
    by the LDAP/NIS domain (which might be different to the DNS domain name).
    Additionally, if hostname is already in long form, it won't try to build
    the fqdn fact from hostname and domain.

diff --git a/lib/facter/domain.rb b/lib/facter/domain.rb
index b1bba4d..5dfead0 100644
--- a/lib/facter/domain.rb
+++ b/lib/facter/domain.rb
@@ -4,14 +4,14 @@ Facter.add(:domain) do
         # steps is important
 
         Facter.value(:hostname)
-        next $domain if defined? $domain and ! $domain.nil?
+        # try to fetch the domain from hostname if long hostname is used.
+        if defined? $fqdn and $fqdn =~ /^([\w-]+)\.(.+)$/
+          next $2
+        end
 
         domain = Facter::Util::Resolution.exec('dnsdomainname')
         next domain if domain =~ /.+\..+/
 
-        domain = Facter::Util::Resolution.exec('domainname')
-        next domain if domain =~ /.+\..+/
-
         if FileTest.exists?("/etc/resolv.conf")
             domain = nil
             search = nil
diff --git a/lib/facter/fqdn.rb b/lib/facter/fqdn.rb
index 5ebc5f5..6271995 100644
--- a/lib/facter/fqdn.rb
+++ b/lib/facter/fqdn.rb
@@ -1,5 +1,9 @@
 Facter.add(:fqdn) do
     setcode do
+        # try to fetch the fqdn from hostname if long hostname is used.
+        Facter.value(:hostname)
+        next $fqdn if defined? $fqdn and ! $fqdn.nil?
+
         host = Facter.value(:hostname)
         domain = Facter.value(:domain)
         if host and domain
diff --git a/lib/facter/hostname.rb b/lib/facter/hostname.rb
index 188efa4..c3ca968 100644
--- a/lib/facter/hostname.rb
+++ b/lib/facter/hostname.rb
@@ -1,12 +1,13 @@
 Facter.add(:hostname, :ldapname => "cn") do
     setcode do
+        require 'socket'
         hostname = nil
-        name = Facter::Util::Resolution.exec('hostname') or nil
+        name = Socket.gethostbyname(Socket.gethostname).first
         if name
             if name =~ /^([\w-]+)\.(.+)$/
                 hostname = $1
-                # the Domain class uses this
-                $domain = $2
+                # the FQDN/Domain facts use this
+                $fqdn = name
             else
                 hostname = name
             end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list