Centos – Automatically generated /etc/hosts is wrong

anacondacentoscentos5kickstartnetworking

I've created a kickstart script to install CentOS 5.5 (32bit) in a fully automated way.

The DNS/DHCP setup correctly gives the system the right hostname in both the forward and reverse lookups.

dig node4.mydomain.com. +short

10.10.10.64

dig -x 10.10.10.64 +short

node4.mydomain.com.

In the state the installed system is right after the installation completed is as follows:

cat /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=yes
GATEWAY=10.10.10.1
HOSTNAME=node4.mydomain.com

echo ${HOSTNAME}

node4.mydomain.com

cat /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
10.10.10.64            node4

My problem is that this automatically generated hosts file is slightly different from the way I want it (or better: the way Hadoop wants it).

The last line should look like this:

10.10.10.64            node4.mydomain.com node4

What do I modify where to fix this?

Thanks.


Edit:
I've tried to find the code that actually creates this file. I've had a look inside the acaconda sources and the setup src rpm but it wasn't done from one of those.
Does anyone here know where to code is located that creates the /etc/hosts file?


I added the following to the %post of my kickstart file which works for my situation:

# =========================
# Force the right hosts file for Hadoop and such
cat > /etc/hosts <<End-of-file
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1     localhost.localdomain localhost
::1           localhost6.localdomain6 localhost6
\$(dig +short \$(hostname))      \$(hostname -f) \$(hostname -s)
End-of-file

Best Answer

Not being familiar with RedHat's kickstart system, I would use a supplemental script to run at the end of installation and set the line the way you want.