Any comments on this one? its hitting me hard on all of my Solaris
boxes.

On Jan 18, 10:45 am, Ohad Levy <[email protected]> wrote:
> This patch removes the relationship between the domain fact and LDAP/NIS
> domain value.
>
> The domain fact represent 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.
> ---
>  lib/facter/domain.rb   |    8 ++++----
>  lib/facter/fqdn.rb     |    4 ++++
>  lib/facter/hostname.rb |    7 ++++---
>  3 files changed, 12 insertions(+), 7 deletions(-)
>
> 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
> --
> 1.6.3.3

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to