Modular kickstart
This describes how to implement a modular kickstart system
for Red Hat Anaconda based systems.
Kickstart HTTP server: 192.168.0.4
Please
create directories according to the picture.
Creating the directories
# cd /var/lib/html
# mkdir -p kickstart/auth
# mkdir -p kickstart/part
# mkdir -p kickstart/post
# mkdir -p kickstart/firewall
# mkdir -p kickstart/config
# mkdir -p kickstart/package
# mkdir -p kickstart/xconfig
# mkdir -p kickstart/interactive
Populating the directories
Each directory can contain a default file. The name of
the default file is directoryname.default. The default
file contains as you could guess default settings. If
you want machine specific settings you create a file
named directory.hostname where hostname is the DNS name
of the machine.
- auth/auth.default
- part/part.default
- post/post.default
- firewall/firewall.default
- config/config.default
- package/package.default
- xconfig/xconfig.default
- interactive.default
Kickstart file ks.cfg
#System language
lang en_US
langsupport --default en_US en_US sv_SE
keyboard sv-latin1
mouse
timezone --utc Europe/Stockholm
rootpw ENTERYOURPASSWORDHERE
#Reboot after installation
reboot
#Use text mode install
text
#System bootloader configuration
bootloader --location=mbr
#Install Red Hat Linux instead of upgrade
install
#Interactive or not
%include /tmp/interactive
#Use FTP installation media
url --url http://192.168.0.4/dist/centos/4/os/i386/
#Use DHCP networking
%include /tmp/network
# Partition info by wget
%include /tmp/part
#System authorization information
%include /tmp/auth
#Firewall configuration
%include /tmp/firewall
#Do not configure the X Window System
%include /tmp/xconfig
%packages
%include /tmp/package
%post
#!/bin/bash
IPADDR=`ifconfig eth0 | grep "inet addr" | cut -d ":" -f 2 | cut -d " " -f 1`
HOST=`dig +short -x $IPADDR | cut -d "." -f 1`
echo $HOST
sleep 10
wget http://192.168.0.4/kickstart/post/post.all -O /tmp/post.all
source /tmp/post.all
post_get()
{
echo $1
wget http://192.168.0.4/kickstart/post/post.$1 -O /tmp/post
source /tmp/post
}
post_get "$HOST"
%pre --interpreter /usr/bin/python
import socket
import os
print "Hostname"
print socket.gethostbyaddr( os.popen("ifconfig").readlines()[1].split()[1][5:])[0][0];
ipaddr = os.popen("ifconfig").readlines()[1].split()[1][5:]
hostname = socket.gethostbyaddr(ipaddr)[0]
host = hostname.split('.')[0]
f = file("/tmp/network","w")
if os.path.exists ("/proc/sys/net/ipv4/conf/eth0"):
f.write ("network --bootproto=dhcp --device=eth0\n")
else:
f.write ("network --bootproto=dhcp --device=eth1\n")
f.close
url = 'wget http://192.168.0.4/kickstart'
# Get config files for machine.configfilename
for file in ['part','package','auth','firewall','xconfig','interactive']:
print("%s/%s/%s.%s -O /tmp/%s" % (url,file,file,host,file))
os.popen("%s/%s/%s.%s -O /tmp/%s" % (url,file,file,host,file)).readlines()
# Otherwise get default file
if not os.path.exists ("/tmp/%s" % file):
print("%s/%s/%s.%s -O /tmp/%s" % (url,file,file,"default",file))
os.popen("%s/%s/%s.%s -O /tmp/%s" % (url,file,file,"default",file)).readlines()
The modular Red Hat kickstart file
Email: Christian Nygaard chris at math.uu.se
RHCE