|
Setting a hostname proved to be a PITA. Although setting a hostname shouldn't at all be any difficult, it proved to need some thought. As I'm managing my workstations with puppet, after provisioning a system when puppetd starts for the very first time, it'll generate a client side certificate based on the hostname at that time. When provisioning systems with either a kickstart based install, regardless of the provisioning being facilitated by cobbler, you'll find that before you reboot the machine, you need to have set the hostname because it's going to use whatever hostname it finds for things like the client side puppet certificate generation. So how do you set the hostname before or at the first boot? Maybe you can set it via DHCP? It'd be pretty easy to create a named host reservation, fair enough. Maybe, you can have hostnames based on the IP address and let the hostname be set by forward and reverse DNS on whatever IP address the machine gets. But what happens when none of the above apply? I thought about setting a parameter on the 'boot prompt' command line, but I couldn't find any pre-defined and usable parameters. However, I've not really been investigating if such parameter exists. You can also set it in the kickstart file, or maybe have a HTTP server generate a kickstart file with a unique hostname. Anyway, here's how I've done it: When installing the machine, append 'hostname=whatever.host.kanarip.com' at the prompt. Because it starts installing using some kickstart file, %post could do nifty stuff. I'm using this: %post CMDLINE=`cat /proc/cmdline` for cmd in ${CMDLINE}; do if [ ! -z "`echo ${cmd} | grep "hostname="`" ]; then hostname=`echo ${cmd} | cut -d'=' -f 2` fi done if [ ! -z "${hostname}" ]; then sed -i -e 's/HOSTNAME=localhost.localdomain/HOSTNAME=${hostname}/g' /etc/sysconfig/network echo "DHCP_HOSTNAME=${hostname}" >> /etc/sysconfig/network fi Not only does this set the hostname, but it also explicitly requests the DHCP server what hostname to update in Dynamic DNS. When your network environment runs that crappy 'feels-like-it-should-work' variant of Directory Services including the network bits like DNS and DHCP, you'll find that operating system that should never have been plugged in to the network, unable to 'just update' -even if you set 'Always update A and PTR records for clients even if they do not request it'. If you have any suggestions, and I suspect you do, feel free to mail me or comment here ;-)
|