I’ve set a hostname which excludes a domain name I’ve been provided with. However when it connects to my puppet master, lots of code fails – eventually I’ve pinned this down the fqdn fact not returning the fully qualified domain name and instead returning the hostname. Is there anyway around this? Perhaps it’s a misconfiguration in puppet or changes to the agent.
If there isn’t, what can I do to resolve it? Should I create a new fact? Find and replace everywhere the fqdn fact is use.
[root@a /]# hostname
a.long.hostname.with.lots.of.required.fields
[root@a /]# hostname -f
a.long.hostname.with.lots.of.required.fields.areallongexample.com
[root@a /]# facter fqdn
a.long.hostname.with.lots.of.required.fields
[root@a /]# facter hostname
a
[root@a /]# facter domain
long.hostname.with.lots.of.required.fields
[centos@a ~]$ facter networking.fqdn
a.long.hostname.with.lots.of.required.fields
[centos@a ~]$ facter networking
{
dhcp => "192.168.0.2",
domain => "long.hostname.with.lots.of.required.fields",
fqdn => "a.long.hostname.with.lots.of.required.fields",
hostname => "a",
interfaces => {
eth0 => {
bindings => [
{
address => "192.168.0.2",
netmask => "255.255.255.0",
network => "192.168.0.0"
}
],
dhcp => "192.168.0.1",
ip => "192.168.0.2",
mac => "00:00:00:00:00:00",
mtu => 9001,
netmask => "255.255.255.0",
network => "192.168.0.0"
},
lo => {
bindings => [
{
address => "127.0.0.1",
netmask => "255.0.0.0",
network => "127.0.0.0"
}
],
ip => "127.0.0.1",
mtu => 65536,
netmask => "255.0.0.0",
network => "127.0.0.0"
}
},
ip => "192.168.0.2",
mac => "00:00:00:00:00:00",
mtu => 9001,
netmask => "255.255.255.0",
network => "192.168.0.0",
primary => "eth0"
}
2
Answers
I created a fact called fqdn and changed the weight for it, it simple runs hostname -f.
No, you haven’t. At least not if the
hostname
outputs you present model the actual system configuration correctly. You’ve configured the machine with a hostname that expresses a different domain name than you were given.A fully-qualified domain name consists of a series of segments separated by periods (
.
). The first segment is a machine-specific name, and the rest is a domain name.It is valid and common to configure a machine such that the
hostname
command returns the fully-qualified domain name, and I find this easiest to work with from a Puppet perspective. Some people prefer to instead configure such that thehostname
command returns the simple hostname, and this can work, too, provided that thednsdomainname
command returns the full domain.Facter assumes that one of those two approaches has been taken, but the outputs of your
hostname
andhostname -f
commands show that your machine is configured differently.hostname
returns a name that looks like a FQDN on account of containing period-separated segments, but it is not the machine’s FQDN. This will very likely cause trouble for more than just Puppet and Facter, which is why it is reasonable for Facter assume that machines are not configured the way yours is.You should fix your system configuration. If the machine’s correct FQDN is
a.long.hostname.with.lots.of.required.fields.areallongexample.com
then you should set either that or simplya
as (its sense of) its hostname. This may require you to dump your current Puppet machine registration and re-register with the new hostname.