[rhn-users] Best Practice for KS Hostname setting

James superfueld at charter.net
Sat Jul 10 02:08:51 UTC 2004


If you are willing to make the installation a little bit interactive, you can just ask the user for the hostname at install time. I'm doing this now and I think it works great. All I have to do after inserting the CD is type the machine's hostname and walk away. Everything else gets handled by either %pre or %post. For example, here's the relevant sections from my own kickstart that will set your hostname:

%pre
# change to new virtual terminal and set stout/stdin there
exec < /dev/tty6 > /dev/tty6
chvt 6
echo -n "Enter hostname: "
read hostname
echo NETWORKING=yes > /tmp/network
echo HOSTNAME=$hostname >> /tmp/network
chvt 1

%post --nochroot
cp /tmp/network /mnt/sysimage/tmp/network

%post
cp /tmp/network /etc/sysconfig/network
. /etc/sysconfig/network
hostname $HOSTNAME

You can do alot more than just this of course, but that's the bare minimum I think. Many thanks to the folks at the kickstart-list at redhat.com discussion list for unlocking the /dev/tty6 redirection stuff for me.

P.S. Here's a tip for registering automatically with RHN: If you're using a kickstart file generated by RHN and you select the "register with RHN automatically" checkbox, it will put the rhnreg_ks command in the %post section ABOVE our hostname-setting code. Since the hostname will still be localhost.localdomain at this point, it will register as profile name "unknown" and hostname "unknown" (I'm assuming it can't reverse lookup it's own IP). To get around this, leave the "register automatically" box unchecked, use post to add a line to /etc/hosts so it can do the reverse lookup, and put your own rhnreg_ks command at the end of %post with the "--profilename $HOSTNAME" arguments.

-James

Andy Ciordia wrote:
> 
> Currently my mentality for Kickstarts have been generalized.  I have our 
> Application Server(s), Database Server(s), Developer Workstation(s) all 
> kickstarting off main profiles (App/DB/Dev).
> 
> Where I am currently at a crossroads is how the identity of the machine 
> is setup. Everything that boots off a kickstart is labled by default 
> localhost.localdomain.. the /etc/host and /etc/sysconfig/network file 
> have to be tweaked by hand.
> 
> How should machine identities be aquired?  I've got their MAC's lining 
> up for DHCP, but since they are static ip's being managed in a ddns 
> framework DHCP doesn't seem to set anything if its outside the dynamic 
> range.
> 
> Otherwise all I see atm are individual KS's for each machine, but that 
> seems self-defeating of having something rollout across many machines.
> 
> Thanks for the pointers,
> -a
> 





More information about the rhn-users mailing list