OVM Lab setup via Kickstart

I have 4 HP DL380 G5’s that I use for my OVM lab.  Nothing fancy but it gets the job done. I use it to test upgrades, patches and just about anything I need to figure out.  As a result, I find myself needing to re-image these machines quite frequently.  I finally got around to setting up a kickstart server a few months ago and eventually added OVM to the mix.  Again- this article is based on an Oracle Linux 6.x system that hasn’t had any kickstart setup done on it yet.  I already posted an entry here about how to set up Kickstart to install an Oracle Linux 6.5 host.  The steps below are mostly the same with a few exceptions.  Hope you enjoy!

** Install additional packages needed **

[root@forge ~]# yum -y install dhcp syslinux xinetd tftp-server httpd

...
...
...

Complete!

 

** Configure web server **

NOTE: You can pick whatever folder you want to use to serve up the images but remember to change them in the files below as well.  I chose to use the standard httpd folder to minimize changes to the httpd.conf file and I wasn’t using this machine for a web server. 

[root@forge ~]# sed -i 's/^Listen .*/Listen {your IP address here}:80/' /etc/httpd/conf/httpd.conf
[root@forge ~]# rm -rf /var/www/html
[root@forge ~]# mkdir -p /tftpboot/pxelinux.cfg
[root@forge ~]# mkdir /tftpboot/ks
[root@forge ~]# ln -s /tftpboot/ /var/www/html
[root@forge ~]# service httpd start
[root@forge ~]# chkconfig httpd on

 

** Configure /etc/sysconfig/dhcpd **

NOTE: I’m assuming you are using eth1 as the interface that will be listening for DHCP requests and responding.  If your machine or VM is multi-homed then you may need to adjust this.

[root@forge ~]# echo 'DHCPDARGS="eth1"' > /etc/sysconfig/dhcpd

 

** Add following entries into /etc/dhcp/dhcpd.conf **

NOTE: The config below will automatically assign a specified IP address to the hosts that match the MAC addresses you code into the config below.  It will also set the hostname for the host accordingly as well.

=== SNIP ===
# Global Options
Allow booting;
Allow bootp;
authoritative;

# Subnet definition
subnet {your network here} netmask {your netmask here} {
# Parameters for the local subnet
option routers               {your router here};
option subnet-mask           {your netmask here};
option domain-name-servers   {your DNS server here};
default-lease-time           21600;
max-lease-time               43200;
# Client IP range
range dynamic-bootp {your starting DHCP address} {your ending DHCP address};
filename  "pxelinux.0";
next-server  {IP address of DHCP server};

host ovm1 {
        hardware ethernet {your MAC address here};
        fixed-address {your IP address here};
        option host-name ovm1;
        }

host ovm2 {
        hardware ethernet {your MAC address here};
        fixed-address {your IP address here};
        option host-name ovm2;
        }

host ovm3 {
        hardware ethernet {your MAC address here};
        fixed-address {your IP address here};
        option host-name ovm3;
        }

host ovm4 {
        hardware ethernet {your MAC address here};
        fixed-address {your IP address here};
        option host-name ovm4;
        }
}
=== SNIP ===

 

** Start DHCPD services **

[root@forge dhcp]# chkconfig dhcpd on
[root@forge dhcp]# service dhcpd start
Starting dhcpd:                                            [OK]
[root@forge dhcp]#

 

** Create folder and copy following contents into /tftpboot/pxelinux.cfg/PXE-OVS{ovm server version} **

=== SNIP ===
  default mboot.c32
  kernel mboot.c32
  append OVM3.3.1/xen.gz --- OVM3.3.1/vmlinuz ro root=/ ks=http://{your IP address here}/ks/OVM3.3.1.ks ksdevice=eth0 ip=dhcp noipv6 --- OVM3.3.1/initrd.img ramdisk_size=65535 noapic
=== SNIP ===

NOTE: If you are putting this information into /tftpboot/pxelinux.cfg/default then leave off the line below:
default mboot.c32

 

** Create link from MAC address of each server to be PXE booted to that PXE file.

NOTE: See end of this entry for script to do this automatically

[root@forge dhcp]# ln -s /tftpboot/pxelinux.cfg/PXE-OVS3.3.1 /tftpboot/pxelinux.cfg/{your MAC address here}

 

** Copy following contents into /tftpboot/ks/OVM3.3.1.ks **

=== SNIP ===
#
# Kickstart for OVM 3.3.1
#
#============================================================================
url --url http://{your IP address here}/osimages/OVM3.3.1
install
reboot
text
skipx
keyboard us
timezone --utc America/Chicago
lang en_US.UTF-8
eula Accepted
authconfig --enableshadow --passalgo=sha512
# root password Way2secure
# ovsagent password Way2secure
rootpw  --iscrypted $6$sc0i5O7V$hvwYPeFMDLO3c.8xGXZPF52kP2ToOUCmwMqTmS7pmaEXm4cAWL4VIBx0MUU9B0umr3lvTNRECzh.0Y7OC6tmA0
ovsagent  --iscrypted $6$sc0i5O7V$hvwYPeFMDLO3c.8xGXZPF52kP2ToOUCmwMqTmS7pmaEXm4cAWL4VIBx0MUU9B0umr3lvTNRECzh.0Y7OC6tmA0
ovsmgmntif eth0
firewall --service=ssh
selinux --disabled
network --onboot yes --device eth0 --bootproto dhcp --noipv6
zerombr yes
bootloader --location=mbr --driveorder=cciss/c0d0 --append="crashkernel=auto rhgb quiet"
clearpart --all --drives=cciss/c0d0
part / --fstype=ext4 --grow --maxsize=51200 --size=1024
part /boot --fstype=ext4 --size=500
part swap --grow --maxsize=11808 --size=11808
part None --fstype=ext4 --grow --size=100
=== SNIP ===

 

** Copy files into /tftpboot **

[root@forge ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@forge ~]# mkdir /tftpboot/OVM3.3.1
[root@forge ~]# cp  {OVM 3.3.1 install media}/isolinux/vmlinuz {OVM 3.3.1 install media}/isolinux/initrd.img {OVM 3.3.1 install media}/isolinux/xen.gz /tftpboot/OVM3.3.1/
[root@forge ~]# cp /usr/share/syslinux/mboot.c32 /tftpboot/

 

** Copy contents of install disk into /tftpboot/osimages/OVM3.3.1 **

[root@forge ~]# mkdir /tftpboot/osimages/OVM3.3.1
[root@forge ~]# mount -o loop {path to ISO of OVM3.3.1} /mnt
[root@forge ~]# rsync -avp /mnt/ /tftpboot/osimages/OVM3.3.1/

 

** Enable TFTP service in xinetd **

[root@forge ~]# sed -i 's/^.*disable.*= yes/\tdisable\t\t\t= no/' /etc/xinetd.d/tftp
[root@forge ~]# sed -i 's/^.*server_args.*= -s \/var\/lib\/tftpboot/\tserver_args\t\t= -s \/tftpboot/' /etc/xinetd.d/tftp
[root@forge ~]# chkconfig xinetd on
[root@forge ~]# service xinetd start
Starting xinetd:                                           [  OK  ]
[root@forge ~]#

 

** Additional kickstart config files **

---SNIP---
#
# Kickstart for OVM 3.2.8
#
#============================================================================
url --url http://{your IP address here}/osimages/OVM3.2.8
install
reboot
text
skipx
mouse none
keyboard us
timezone --utc America/Chicago
lang en_US.UTF-8
eula Accepted
authconfig --enableshadow --passalgo=sha512
# root password Way2secure
# ovsagent password Way2secure
rootpw  --iscrypted $6$sc0i5O7V$hvwYPeFMDLO3c.8xGXZPF52kP2ToOUCmwMqTmS7pmaEXm4cAWL4VIBx0MUU9B0umr3lvTNRECzh.0Y7OC6tmA0
ovsagent  --iscrypted $6$sc0i5O7V$hvwYPeFMDLO3c.8xGXZPF52kP2ToOUCmwMqTmS7pmaEXm4cAWL4VIBx0MUU9B0umr3lvTNRECzh.0Y7OC6tmA0
ovsmgmntif eth0
firewall --disabled
selinux --disabled
network --onboot yes --device eth0 --bootproto dhcp --noipv6
zerombr yes
bootloader --location=mbr --driveorder=cciss/c0d0 --append="crashkernel=auto rhgb quiet"
clearpart --all --drives=cciss/c0d0
part / --fstype=ext3 --grow --maxsize=51200 --size=1024
part /boot --fstype=ext3 --size=500
part swap --grow --maxsize=11808 --size=11808

%packages
@base
@core
@ovs-virtualization
bridge-utils
tftp
---SNIP---

 

** Makeactive script to create symbolic links to PXE boot files **

NOTE: replace the MAC addresses in the variable “mac” below with your own.  This script will essentially search for all the files in $tftpboot_path starting with “PXE-” and ask you which version of the PXE file you would like to make active on next kickstart boot.  Then the script will automatically create a symbolic link from the file representing the version you’ve chosen to the MAC address of the host(s) that is/are to boot.  Note also that the format of the MAC address is slightly different from that which we’ve seen so far.  You have to use a – inbetween the octets, and the MAC address should be preceeded by a 01- and then the M

---SNIP---
#!/bin/bash

tftpboot_path=/tftpboot/pxelinux.cfg
version=(`ls -1 /tftpboot/pxelinux.cfg/PXE*`)
mac=(01-00-16-35-6a-ee-f7 01-00-16-35-6b-18-a7 01-00-16-35-6b-4d-b3 01-00-16-35-6b-7f-df)

clear
echo "PXE Boot switcher.  Choose from versions of OVM Server available:"
echo

c=0
numversions=${#version[*]}
while [ $c -lt $numversions ]
do
        v=`echo ${version[c]} | awk -F/ '{print $NF}' | tr -d "PXE-"`
        echo "[$c - $v]"
        c=$((c+1))
done
echo
read -p "Choose: " sel

options=`expr $numversions - 1`
if [ $sel -gt $options ]
then
        echo "Error. must choose from 0-$options."
        echo
        exit
fi

rm $tftpboot_path/01-*
c=0
nummacs=${#mac[*]}
cd $tftpboot_path
while [ $c -lt $nummacs ]
do
        vers=`echo ${version[sel]} | awk -F/ '{print $NF}'`
        ln -s $vers ${mac[c]}
        c=$((c+1))
done
---SNIP---

 All Done!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s