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

Let me walk you through my steps.

  • I have a node with RHEL 5.10 base OS; the / etc / hosts file is empty.
  • Running the CLI "hostname -f" gives server1-nodex.domain.com, which is correct.
  • I am downloading node successfully; when i do "knife show node node_name" i see correct FQDN like server1-nodex.domain.com
  • I run the recipe with the creation of the / etc / hosts file and put it in that format; notice the alias (nodex) after the IP . I NEED this format!

    10.22.10.10 nodex server1-nodex.domain.com

  • Now if I make a knife node show node_name The Chef shows the FQDN as "nodex." Yes???
  • Of course, running CLI "hostname -f" also gives "nodex" Huh ???
  • Just to check, I'm old, but I create / etc / hosts file in this format; note that the alias now appears after the FQDN on the line (I don't need that)

    10.22.10.10 server1-nodex.domain.com nodex

  • Now if I make a knife node show node_name the chef shows the correct FQDN, just like "hostname -f"

Why does Chef do this with my FQDN based on what's in the / etc / hosts file? I have a pre-chef setup process (shell scripts) that sets up the / etc / hosts file the way I want it and the FQDN is NOT affected?

Is this a "mistake" or at least an unwanted chef side effect?

+3


source to share


2 answers


I'm pretty sure this is not the chef's fault, but the init scripts on your Linux box. They read /etc/hosts

to determine how to set the hostname.

Take a look /etc/sysconfig/network-scripts



You can override this value in /etc/sysconfig/network

.

+1


source


Host file format:

IP_address canonical_hostname [aliases...]

      

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



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

The chef (ooh) uses the resolver to get fqdn. As you make changes to / etc / hosts, you change the resolver's answer, it changes Chef's answer.

+1


source







All Articles