4

I'm using the CentOS 6 netinstall ISO with some kickstart files on an http server. When the ISO boots I hit TAB and enter the boot options asknetwork ks=http://<ip-address>/path/to/kickstart.ks.

My kickstart files do not have a network parameter, so it should be prompting. When I leave out asknetwork it tries to use DHCP. With asknetwork it only prompts for IP information.

Unfortunately anaconda is hell bent on automatically discovering the hostname, which ends up being a reverse DNS lookup of the IP, or localhost.localdomain if nothing was found.

Is there a way to make anaconda prompt for the hostname, or some way to pre-enter it through a custom boot option?

There used to be network --bootproto=query for CentOS 5, but this no longer works in 6.

Luke
  • 1,892
  • 4
  • 22
  • 27
  • _There used to be network --bootproto=query for CentOS 5, but this no longer works in 6._ It is still there, and it works (I used it a few weeks ago). The trick seems to be that if the Kernel passes on any network information to Anaconda, then `--bootproto-query` will silently be ignored. – Stefan Lasiewski Jan 28 '13 at 23:00

3 Answers3

4

I set the hostname in the kickstart file directly.

If you're trying to reuse the same template, you could get creative and use a bit of PHP to pass something to the installer. Kickstart files are http, so you could do something like:

ks=http://repo.brazzers.com/ks/kickstart.php?hostname=kitty

...where kitty is a variable in the kickstart file that populates the --hostname= parameter

Or the better route is to use a more robust provisioning framework like Cobbler.

ewwhite
  • 194,921
  • 91
  • 434
  • 799
1

I prefer this method using bash:

%include /tmp/network.txt

%pre
#!/bin/sh
exec < /dev/tty3 > /dev/tty3 2>&1
chvt 3
hn=""

while [ "$hn" == "" ]; do
 clear
 echo " *** Please enter the following details: *** "
 echo
 read -p "Hostname: " hn
done
clear
chvt 1
echo "network --device eth0 --bootproto static --noipv6 --hostname ${hn}" > /tmp/network.txt
Dejan
  • 248
  • 1
  • 2
  • 12
0

I was trying to do this with virt-install and found a blog article with an excellent solution to this. The solution uses the /proc/cmdlines passed to the kernel at boot time to extract a hostname using a pre kickstart section and write a temporary file that is then included in the main kickstart section.

http://monzell.com/post/15547967527/automatically-set-the-hostname-during-kickstart

The blog was for kickstarting VMs in KVM. But I don't see any reason this wouldn't work in any other kickstart scenario where you can pass the kernel boot arguments easily.

Andy Shinn
  • 4,131
  • 8
  • 38
  • 55