[Puppet Users] Re: ANNOUNCE: Facter 1.5.1 - issue on freebsd

ADNET Ghislain
Thu, 18 Sep 2008 07:06:54 -0000

i still have issue with the facter 1.5.1/2 on my freebsd boxes. It seems
unable to find the ''domain'' any more. I finish by taking the
domain from
the ''search'' parameter in the resolv.conf wich is not good at
all for me.

i browsed the code and i cannot find significant differences between the
1.5.0 and 1.5.2 for determining the hostname.

I see that facter use the ''hostname'' command to get the
hostname. Would
it be better to use:

require "socket"
Socket.gethostname

as it is pure ruby and does not involve an external program ?



Also in facter 1.5.2 if i modify the hostname code from:

            if name =~ /^([\w-]+)\.(.+)$/
                hostname = $1
                # the Domain class uses this
                $domain = $2
            else
                hostname = name
            end


to
            if name =~ /^([\w-]+)\.(.+)$/
                hostname = $1
                # the Domain class uses this
                $domain = ''mydomain.net''
            else
                hostname = name
            end


(see i assign $domain a static value) facter still do not report the
domain name as mydomain.net and continue to look in /etc/resolv.conf.

It seems the domain value do not return to the domain.rb file when
called in hostname.rb or that it is overwritten. If i remove the part
that search the resolv.conf then it work again. This part seems to
ovverride the first one, eash call of Facter.add(:domain) overwrite the
one that is just before it it seems.



Also in the facter code in (lib/facter/domain.rb) resolv.conf part it
take the comments instead of just ignore them, if i comment the search
line it still use it:

 if line =~ /search\s+(\S+)/
                        value = $1
                        break
                    end

the regex do not filter comments. should be something like

 if line =~ /^\s*search\s+(\S+)/
                        value = $1
                        break
                    end



 From the resolv.conf manual i have :

     search      Search list for host-name lookup.  The search list is nor-
                 mally determined from the local domain name; by default, it
                 contains only the local domain name.  This may be
changed by
                 listing the desired domain search path following the search
                 keyword with spaces or tabs separating the names.  Most
                 resolver queries will be attempted using each component of
                 the search path in turn until a match is found.  Note that
                 this process may be slow and will generate a lot of network
                 traffic if the servers for the listed domains are not
local,
                 and that queries will time out if no server is
available for
                 one of the domains.



  therefor how can this be used to have the hostname ? Or this should
refer to the default hostname as returned by host or this is nothing
related to it therefor it seems that this part is not usefull at all ?


--
Cordialement,
Ghislain