tips‎ > ‎

Cobbler


my Default kickstart file

 - save in /var/lib/cobbler/kickstarts/default.ks

#platform=x86, AMD64, or Intel EM64T
# System authorization information
# auth  --useshadow  --enablemd5  --enablenis --nisdomain=domain --nisserver=server
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disable
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# keyboard sg-latin1
# System language
lang en_US.UTF-8
# langsupport en_US.UTF-8
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot

#Root password
rootpw --iscrypted $default_password_crypted

# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  Europe/Zurich
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr

%include /tmp/part-include
# RHEL install Key
key $getVar('rhel_key','XXXXXXXXXXXXXXX')

%pre
$SNIPPET('log_ks_pre')
$kickstart_start
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
# useful to debug pre/post
# chvt 3
# exec < /dev/tty3 > /dev/tty3 2>/dev/tty3
# ge  the number of hard disks and there names
set \$(list-harddrives)
let numd=\$#/2
d1=\$1
d2=\$3

if [ \$numd = 2 ]; then # only one disk
    cat <<- EOpart > /tmp/part-include
 clearpart --initlabel --drives=\$d1,\$d2
 part /boot --fstype ext3 --size=256 --ondisk=\$d1 --asprimary
 part swap --size=8192 --ondisk=\$d1
 part swap --size=8192 --ondisk=\$d2
 part / --fstype ext3 --size=8000 --ondisk=\$d1
 part pv.100001 --size=10 --grow --ondisk=\$d2
 part pv.100000 --size=10 --grow --ondisk=\$d1
 volgroup vg.data --pesize=32768 pv.100000 pv.100001
 logvol /data --fstype ext3 --name=data --vgname=vg.data --size=10 --grow
EOpart

else
      cat <<- EOpart > /tmp/part-include
 clearpart --initlabel --drives=\$d1
 part /boot --fstype ext3 --size=256 --ondisk=\$d1 --asprimary
 part swap --size=8192 --ondisk=\$d1
 part / --fstype ext3 --size=8000 --ondisk=\$d1
 part pv.100000 --size=10 --grow --ondisk=\$d1
 volgroup vg.data --pesize=32768 pv.100000
 logvol /data --fstype ext3 --name=data --vgname=vg.data --size=10 --grow
EOpart

fi

%packages
$SNIPPET('packages_workstation_5')

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
## $SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')

# Custom Customer Gunge

$SNIPPET('post_5ws_green')


# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$kickstart_done
# End final steps

Snipperts

Post_5ws



cat /dev/null >/etc/resolv.conf

# But we need the hostname for NIS.
cat >>/etc/hosts <<EOF
x.x.x.x   tex
y.y.y.y    pixie
EOF

# Turn off services which don't work in the brown network.
chkconfig postfix off
chkconfig rhnsd off


# Setup automounter and some other stuff
rpm -Uvh --force http://x.x.x.x/packages/workstation/j2sdk-1_4_2_14-linux-i586.rpm
rpm -Uvh --force http://x.x.x.x/packages/workstation/AdobeReader_enu-8.1.2-1.i486.rpm
rpm -Uvh --force http://x.x.x.x/packages/workstation/ICAClient-10.6-1.i386.rpm



mkdir /data/scratch
chmod a+rwx+t /data/scratch
ln -sf /data/scratch /scratch1


service portmap start
service ypbind start
service autofs start


<SNIP>
wget -q -P/var/pi-scripts http://$server/scripts/pi-gtsw

chmod +x /var/pi-scripts/pi-??sw
/var/pi-scripts/pi-??sw

# enable sysrq
perl -pi -e 's/kernel.sysrq *= *0/kernel.sysrq = 1/' /etc/sysctl.conf


add system to cobbler script

#!/bin/bash
#add a workstation to cobbler - uses nis to check host mac and netgroup
if [ $# -ne 1 ];then
        echo "usage $0 <workstation name registered in nis >"
        exit 1
fi


hostname=$1
#verify hostname exists in nis
ypmatch $hostname hosts > /dev/null 2>&1
if [ 0 -ne $? ];then
        echo "ERROR:    name not found in nis - did you add and make?"
        exit 1
fi
#verify mac



#check if it's already in cobbler
ypmatch $hostname ethers > /dev/null 2>&1
if [ 0 -ne $? ];then
        echo "ERROR:    mac not found in nis - did you add and make?"
        exit 1
fi

cobbler system list |grep $hostname> /dev/null 2>&1
if [ 0 -ne $? ];then
        COBOP=add
else
        COBOP=edit
fi
#finally check if it's in the netgroup
#cant check if the zfs shares are updated but then again i cant test for stupidy ether!
ypcat netgroup |grep $hostname > /dev/null 2>&1
if [ 0 -ne $? ];then
        echo " add the system to the netgroup and run make AND fix_zfs_shares"
        exit 1
fi


mac=`ypmatch $hostname ethers|awk '{print $1}'`

ip=`ypmatch $hostname hosts|awk '{print $1}'`

echo " $COBOP $hostname in cobbler with $mac and $ip"
cobbler system $COBOP --name $hostname --netboot-enabled=true --hostname=$hostname --gateway="10.128.86.1" --profile="RHEL5.5-x86_64" --ip-address=$ip --mac-address=$mac --static="True" --dhcp-tag=$hostname --subnet=255.255.255.0 --name-servers=10.128.86.102 --ksmeta "nis=1" --dns-name=$hostname
if [ 0 -ne $? ];then
        echo "cobbler failed for somereason - look above"
        exit 1
else
        cobbler sync
        cobbler system report --name=$hostname
        echo "${COBOP}ed in cobbler"
fi



Comments