Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
Check that the DHCP server is actually returning a Domain Name (option 15). I do the same setup and /etc/hosts is formatted correctly. –  Mark Wagner Feb 3 '11 at 17:23
    
@embobo: I'm using dnsmasq for this setup: What's the best way to check that the DHCP server really does this correctly? –  Niels Basjes Feb 3 '11 at 20:36
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Thanks, see the bottom of my question on how I actually did it. –  Niels Basjes Feb 7 '11 at 14:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.