Chris F
Chris F

Reputation: 16793

Is this a Chef/ohai bug when dealing with FQDNs?

Let me walk you through my steps.

Why does Chef do this to my FQDN based on what's in the /etc/hosts file? I have a pre-Chef configuration process (shell scripts) that configures the /etc/hosts file the way I want it, and the FQDN does NOT get affected?

Is this a "bug" or at least an undesirable side effect in Chef?

Upvotes: 3

Views: 1193

Answers (2)

btm
btm

Reputation: 11

The hosts file format is:

IP_address canonical_hostname [aliases...]

That is, the first hostname after the IP address is the unique name for this system and anything after that is an alias. You have them reversed in your example.

Typically by default your resolver is configured to look in your hosts file for hostnames first, then use the DNS system (see /etc/resolv.conf and /etc/host.conf). So running 'hostname -f' on your system to get the FQDN is going to be affected by your changes to your /etc/hosts file.

Chef (ohai) uses the resolver to get the fqdn. Since you're changes to /etc/hosts is changing the resolver's answer, it is changing Chef's answer.

Upvotes: 1

I am pretty sure this is not Chef's fault, but the init scripts on your Linux box. They read /etc/hosts to determine how to set the hostname.

Look in /etc/sysconfig/network-scripts

You should be able to override this in /etc/sysconfig/network.

Upvotes: 1

Related Questions