I got to play with this recently at work and thought that I would write this as a reminder before I forget 🙂 First things first, you need a CentOS6 server and then install the following packages yum install cobbler dhcp. Then edit your DHCP daemon, you can use ranges but I prefer static DHCP (in this example, 192.168.66.200 is the cobbler server AND the DNS):
ddns-update-style interim; allow booting; allow bootp; ignore client-updates; set vendorclass = option vendor-class-identifier; subnet 192.168.66.0 netmask 255.255.255.0 { option routers 192.168.66.1; option domain-name-servers 192.168.66.200; option subnet-mask 255.255.255.0; filename "/pxelinux.0"; default-lease-time 21600; max-lease-time 43200; next-server 192.168.66.200; option domain-name "frlinux.eu"; } host lucifer { hardware ethernet 34:66:DE:AD:BE:EF; fixed-address 192.168.66.66; option host-name "lucifer"; option routers 192.168.66.1; filename "/pxelinux.0"; next-server 192.168.66.200; }
Then you have to import a distro into cobbler. I have downloaded the ISO DVD for CentOS6, just should be called something like: CentOS-6.2-x86_64-bin-DVD1.iso. Then mount it like this: mount -o loop CentOS-6.2-x86_64-bin-DVD1.iso /media. It is now time to import that shit, simple one as it turns (carefully check out that it does not return any errors or you are doomed):
cobbler import --path=/media --name=CentOS6-x86_64
You should run cobbler check to make sure it all works, fix whatever it tells you to.
Provided that you have repos correctly configured, it will grab them all for you very nicely. You can then add a box:
cobbler system add --name=lucifer --profile=CentOS6-x86_64 --mac=34:66:DE:AD:BE:EF --ip-address=192.168.66.66 --subnet=255.255.255.0 --hostname=lucifer --netboot=y --gateway=192.168.66.1
At this point, you need a kickstart file, here is mine for CentOS6:
#version=RHEL6 install # reboot after install reboot # textmode installer text # source of netinstall info url --url=$tree lang en_US.UTF-8 keyboard us network --bootproto=dhcp --device=eth0 --onboot=on $yum_repo_stanza $SNIPPET('network_config') rootpw --iscrypted $encryptyourownrootpasswordrighthereasthisonewillnotwork/ firewall --disable authconfig --enableshadow --passalgo=sha512 --enablefingerprint selinux --disabled skipx timezone UTC bootloader --driveorder=sda --append="crashkernel=auto edd=off" clearpart --initlabel --drives=sda part /boot --fstype=ext4 --asprimary --size=200 part swap --fstype=swap --asprimary --size=12000 part / --fstype=ext4 --fsoptions=noatime,nodiratime,logbufs=8 --asprimary --size=20000 --grow #repo --name="CentOS" --baseurl=http://192.168.66.200/cobbler/ repo --name="CentOS-epel" --baseurl=http://repo.somewhere.on.the.web/6.2/epel/ repo --name="CentOS-updates" --baseurl=http://repo.somewhere.on.the.web/6.2/updates/ %pre $SNIPPET('log_ks_pre') $kickstart_start $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end %packages @core @server-policy $SNIPPET('func_install_if_enabled') yum openssh-server openssh-clients pam screen man wget vim-enhanced bind-utils mlocate parted nano ntpdate %end %post $yum_config_stanza $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') $SNIPPET('post_anamon') export PATH=/usr/bin:/bin:/usr/sbin:/sbin $SNIPPET('log_ks_post') ### Repo Setup ### rm -f /etc/yum.repos.d/CentOS* rm -f /etc/yum.repos.d/cobbler-config.repo cat <<-EOF > /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base baseurl=http://repo.somewhere.on.the.web/6.2/base enabled=1 gpgcheck=0 [updates] name=CentOS-$releasever - Updates baseurl=http://repo.somewhere.on.the.web/6.2/updates enabled=1 gpgcheck=0 [epel] name=CentOS-$releasever - EPEL baseurl=http://repo.somewhere.on.the.web/6.2/epel enabled=1 gpgcheck=0 EOF ### Sync Time ### ntpdate ntp.hea.net $SNIPPET('kickstart_done') %end
All going well cobbler sync should not return any errors. I would also check that all the system kickstart works, you can use the following:
cobbler system getks --name=lucifer
As a bonus, here is a configuration for centos6 VMs, copy that file under /var/lib/cobbler/kickstarts/centos6-vm.ks
#version=RHEL6 install # reboot after install reboot # textmode installer text # source of netinstall info url --url=$tree lang en_US.UTF-8 keyboard us network --bootproto=dhcp --device=eth0 --onboot=on $yum_repo_stanza $SNIPPET('network_config') rootpw --iscrypted $replacewithawesomerootpasswordinencryptedform/ firewall --disable authconfig --enableshadow --passalgo=sha512 --enablefingerprint selinux --disabled skipx timezone UTC bootloader --driveorder=vda --append="crashkernel=auto edd=off" # Boot/Disk configuration bootloader --location=mbr zerombr clearpart --all --initlabel %include /tmp/partition-setup repo --name="CentOS-epel" --baseurl=http://repo.somewhere.on.the.web/6.2/epel repo --name="CentOS-updates" --baseurl=http://10.16.1.107/6.2/updates %pre #raw #!/bin/bash set $(list-harddrives) FIRSTDEV=$1 cat <<endpart > /tmp/partition-setup part /boot --fstype=ext4 --asprimary --size=200 part swap --fstype=swap --asprimary --size=2048 part / --fstype=ext4 --fsoptions=noatime,nodiratime --asprimary --size=20000 --grow endpart #end raw $SNIPPET('log_ks_pre') $kickstart_start $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end %packages @core @server-policy $SNIPPET('func_install_if_enabled') yum openssh-server openssh-clients pam screen man wget vim-enhanced bind-utils mlocate parted puppet nano ntpdate %end %post $yum_config_stanza $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') $SNIPPET('post_anamon') export PATH=/usr/bin:/bin:/usr/sbin:/sbin $SNIPPET('log_ks_post') ### Repo Setup ### rm -f /etc/yum.repos.d/CentOS* rm -f /etc/yum.repos.d/cobbler-config.repo cat <<-EOF > /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base baseurl=http://repo/centos6 enabled=1 gpgcheck=0 [updates] name=CentOS-$releasever - Updates baseurl=http://repo/centos6-updates enabled=1 gpgcheck=0 [epel] name=CentOS-$releasever - EPEL baseurl=http://repo/centos6-epel enabled=1 gpgcheck=0 EOF ### Sync Time ### ntpdate ntp.hea.net $SNIPPET('kickstart_done') %end
Last but not least, say you are using console for your servers, you can change this easily by doing: cobbler profile edit –name=CentOS6-x86_64 –kopts=”console=ttyS1,115200n8″
That’s all kids, have fun!