Tuesday 22 February 2011

Kickstart a machine using Cobbler

Setup Epel
[root@dhcp ~]# rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Install Cobbler
[root@dhcp ~]# yum install -y cobbler

Add 25151 to selinux
[root@dhcp ~]# semanage port -a -t http_port_t -p tcp 25151

Turn on autostart
[root@dhcp ~]# chkconfig xinetd on
[root@dhcp ~]# chkconfig httpd on
[root@dhcp ~]# chkconfig cobblerd on

Start Services
[root@dhcp ~]# service httpd start
[root@dhcp ~]# service cobblerd start
[root@dhcp ~]# service xinetd start

Check Cobbler
[root@dhcp ~]# cobbler check

Fix any issues that cobbler check brings up

Edit the firewall
 [root@dhcp ~]# vim /etc/sysconfig/iptables

Add

-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 25151 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 69 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 69 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT

Sync Cobbler
[root@dhcp ~]# cobbler sync

Import a distro into cobbler
[root@dhcp ~]# cobbler import --path=/mnt/cdrom/ --name=centos5 --arch=i386

Add a server to cobbler
[root@dhcp ~]# cobbler system add --name=00:0c:29:e5:bb:a0 --profile=centos5-i386
Disable selinux for tftpd
[root@dhcp ~]# setsebool -P tftpd_disable_trans true

Sunday 20 February 2011

Configure PXE-boot

Install netboot
[root@dhcp ~]# yum install system-config-netboot -y

Set Auto Start
[root@dhcp ~]# chkconfig tftp on
[root@dhcp ~]# chkconfig xinetd on

Turn on xinetd
[root@dhcp ~]# service xinetd start

Share installation tree
NFS
[root@dhcp ~]# vim /etc/exports
add
/mnt/rhel5-i386 192.168.48.0/24(ro)

[root@dhcp ~]# chkconfig nfs on
[root@dhcp ~]# service nfs start

[root@dhcp ~]# showmount -e
Export list for dhcp:
/mnt/rhel5-i386 192.168.48.0/24

PXE Config
pxeos -a -i "<description>" -p <NFS|HTTP|FTP> -D 0 -s server.example.com \
-L <location> -k <kernel> -K <kickstart> <os-identifer>

 [root@dhcp ~]# pxeos -a -i "RHEL 5 i386" -p NFS -D 0 -s 192.168.48.199 -L /mnt/rhel5-i386 RHEL5-I386

New Folder created
[root@dhcp ~]# ll /tftpboot/linux-install/RHEL5-I386/
-rw-r--r-- 1 root root 7500081 Feb 20 16:23 initrd.img
-rw-r--r-- 1 root root      78 Feb 20 16:23 ks.cfg
-rw-r--r-- 1 root root 1875796 Feb 20 16:23 vmlinuz
Add to /etc/dhcpd.conf
allow booting;
allow bootp;
class "pxeclients" {
        match if substring(option vendor-class-identifier,0, 9) = "PXEClient";
        next-server 192.168.48.199;
        filename "linux-install/pxelinux.0";
}
Check and restart dhcp
[root@dhcp ~]# service dhcpd configtest
[root@dhcp ~]# service dhcpd restart

Set up and configure DHCP

Install
[root@dhcp ~]# yum install dhcp -y

Turn on auto
[root@dhcp ~]# chkconfig dhcpd on

Base config
[root@dhcp ~]# cat /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample > /etc/dhcpd.conf

Example Config
ddns-update-style interim;
ignore client-updates;
subnet 192.168.48.0 netmask 255.255.255.0 {
        option routers                  192.168.48.1;
        option subnet-mask              255.255.255.0;
        option domain-name              "example.com";
        option domain-name-servers      192.168.48.2;
        option time-offset              -18000; # Eastern Standard Time
        range 192.168.48.100 192.168.48.120;
        range dynamic-bootp 192.168.48.50 192.168.48.80;
        default-lease-time 21600;
        max-lease-time 43200;
}

Check config
[root@dhcp ~]# service dhcpd configtest

Start Service
[root@dhcp ~]# service dhcpd start