fqdn on puppet clients

800 views
Skip to first unread message

Bjorge Solli

unread,
Sep 8, 2011, 7:36:22 AM9/8/11
to puppet...@googlegroups.com
How is fqdn generated?

On my system it is set to it011064.uib.no, but it really should be set
to it011064.klientdrift.uib.no. Reverse dns and hostname is correct:

root@it011064:~# facter --puppet | grep ^fqdn
fqdn => it011064.uib.no
root@it011064:~# hostname
it011064
root@it011064:~# host $(hostname)
it011064.klientdrift.uib.no has address 129.177.11.64
root@it011064:~# host $(host $(hostname)|awk '{ print $4 }')
64.11.177.129.in-addr.arpa domain name pointer it011064.klientdrift.uib.no.

Bj�rge

Ken Barber

unread,
Sep 8, 2011, 7:45:16 AM9/8/11
to puppet...@googlegroups.com
Hi Bjørge,

The clue is in looking at the code for the 'fqdn' fact:

<snippet>
host = Facter.value(:hostname)
domain = Facter.value(:domain)
if host and domain
[host, domain].join(".")
</snippet>

And drilling into the 'domain' fact:

<snippet>
if name = Facter::Util::Resolution.exec('hostname')
if name =~ /.*?\.(.+$)/
$1
end
elsif domain = Facter::Util::Resolution.exec('dnsdomainname')
domain if domain =~ /.+\..+/
elsif FileTest.exists?("/etc/resolv.conf")
domain = nil
search = nil
File.open("/etc/resolv.conf") { |file|
file.each { |line|
if line =~ /domain\s+(\S+)/
domain = $1
elsif line =~ /search\s+(\S+)/
search = $1
end
}
}
next domain if domain
next search if search
end
</snippet>

So the 'domain' part is worked out by:

* Stripping the domain part from the 'hostname' command OR
* Extracting it from the 'dnsdomainname' command OR
* Grabbing it from /etc/resolv.conf by looking at domain and then search

ken.

> Bjørge
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>

--
"Join us for PuppetConf, September 22nd and 23rd in Portland, OR:
http://bit.ly/puppetconfsig"

Bjorge Solli

unread,
Sep 8, 2011, 10:03:30 AM9/8/11
to puppet...@googlegroups.com
Hi Ken!

Thanks for the reply!

The first two could be solved as one using 'hostname --fqdn', meybe even
the third one.

I decided we should solve this the proper way and update dhcp to specify
option domain-name klientdrift.uib.no uib.no

But since our clients will wander around the globe we want to specify
the certname in the puppet.conf. Is there any other caveates when it
comes to naming we should know about?

Bj�rge

On 08/09/11 13:45, Ken Barber wrote:
> Hi Bj�rge,

>> Bj�rge

Ken Barber

unread,
Sep 8, 2011, 10:30:32 AM9/8/11
to puppet...@googlegroups.com
> The first two could be solved as one using 'hostname --fqdn', meybe even
> the third one.

Perhaps the methodology chosen was more compatible with multiple UNIX
operating systems. For example hostname --fqdn doesn't seem to work on
Mac OS X. A lot of facter code may appear quirky on the surface for
this exact reason.

> I decided we should solve this the proper way and update dhcp to specify
> option domain-name klientdrift.uib.no uib.no
>
> But since our clients will wander around the globe we want to specify
> the certname in the puppet.conf. Is there any other caveates when it
> comes to naming we should know about?

Not off the top of my head ... perhaps someone else may provide input
as I haven't really experimented with this kind of setup.

ken.

michaelkrieg

unread,
Sep 8, 2011, 7:40:21 AM9/8/11
to Puppet Users
Hi,

what says "hostname -f"? What about your /etc/hosts and /etc/
hostname ?

Regards,
Michael

Bjorge Solli

unread,
Sep 9, 2011, 2:41:07 AM9/9/11
to puppet...@googlegroups.com
Indeed it was wrong in /etc/hosts, but this whould be ok when DHCP is
set up differently.

Thanks
Bj�rge

Reply all
Reply to author
Forward
0 new messages