Cobbler installation on CentOS/RHEL

From Define Wiki
Jump to navigation Jump to search

Pre-Requisits

For this installation, we will need to have the following services installed: dhcp, bind & apache.

Install with the following yum command:

yum install httpd dhcp bind

Add syslinux too

yum install syslinux

dhcp from a specific interface

If necessary, the dhcpd service can be restricted to servicing dhcp requests on just one port. To do this, edit the /etc/sysconfig/dhcpd file and set the following line:

DHCPDARGS=eth1

RedHat 7 NOTE: This file is not used any more in RHEL 7. The dhcp server only listens to dhcp requests from ports that are configured with a subnet block (in /etc/dhcp/dhcpd.conf file).

Adding the EPEL Repo to get cobbler

Download http://mirrors.coreix.net/fedora-epel/5/i386/epel-release-5-4.noarch.rpm (or whatever is suitable for the installed OS):

wget http://mirrors.coreix.net/fedora-epel/5/i386/epel-release-5-4.noarch.rpm

And install:

rpm -ivh epel-release-5-4.noarch.rpm

RHEL 7

rpm -Uvh http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel//7/x86_64/e/epel-release-7-5.noarch.rpm
subscription-manager repos --enable rhel-7-server-optional-rpms

Install cobbler

Install using yum:

yum install cobbler cobbler-web

Check apache is working

Restart httpd:

service httpd restart

The following error might occur:

Starting httpd: Syntax error on line 10 of /etc/httpd/conf.d/cobbler.conf:
Invalid command 'WSGIScriptAliasMatch', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]

If this error occurs, firstly remove mod_python:

rpm -e mod_python

Then, create a mod_wsgi config file:

cat > /etc/httpd/conf.d/05-load-wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so

And finally restart apache:

service httpd restart

Add a few more packages to satisfy some cobbler requirements

Install debmirror with yum (needed to manage debian deployments):

yum install debmirror

RedHat 7 note: Package debmirror is not available, yet, for RHEL 7.

Install pykickstart with yum (A python library for manipulating kickstart files):

yum install pykickstart

Edit xinet.d/rsync file

Edit /etc/xinetd.d/rsync and change disable to no:

service rsync
{
        disable = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

Edit /etc/debmirror.conf for proper Debian support

Edit /etc/debmirror.conf and comment dists and arches lines:

# Download options
$host="ftp.debian.org";
$user="anonymous";
$passwd="anonymous@";
$remoteroot="/debian";
$download_method="ftp";
# @dists="sid";
@sections="main,main/debian-installer,contrib,non-free";
# @arches="i386";
# @extra_dirs="";
# @ignores="";
. . . . .

Configure cobbler

Get cobbler to manage dhcp and dns by setting the following in /etc/cobbler/settings:

manage_dhcp: 1
manage_dns: 1

Set server ip addresses in /etc/cobbler/settings:

next_server: 172.28.0.100
server: 172.28.0.100

Confirm the following are set in /etc/cobbler/modules.conf:

[dns]
module = manage_bind

[dhcp]
module = manage_isc

Edit /etc/cobbler/dhcp.template with relevant network information (for example):

# ******************************************************************
# Cobbler managed dhcpd.conf file
#
# generated from cobbler dhcp.conf template ($date)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
#
# ******************************************************************
	
ddns-update-style interim;
	
allow booting;
allow bootp;
	
ignore client-updates;
set vendorclass = option vendor-class-identifier;
	
subnet 172.28.0.0 netmask 255.255.0.0 {
     option routers             172.28.0.100;
     option domain-name-servers 10.0.0.1;
     option subnet-mask         255.255.0.0;
     range dynamic-bootp        172.28.0.101 172.28.0.200;
     filename                   "/pxelinux.0";
     default-lease-time         604800;
     max-lease-time             604800;
     next-server                172.28.0.100;
}
. . . . .

Attempt to start dhcpd:

service dhcpd restart

NB: if the dhcpd service isn't running and it fails to start, it may be because the default /etc/dhcpd.conf file is blank. Enter the above information and start the dhcpd service (it needs to be running for cobbler sync (below) to complete fully). The content of /etc/dhcpd.conf will be overwritten with the contents of /etc/cobbler/dhcp.template once cobbler sync has been performed.

Run cobbler check:

cobbler check

Run cobbler sync:

cobbler sync

Import a CentOS ISO for deployment

Mount a the CentOS ISO file to a local folder, for example:

mount -o loop ./CentOS-5.7-x86_64-bin-DVD-1of2.iso /mnt

Import the ISO into cobbler:

cobbler import --name=CentOS_5.7_X86_64 --path=/mnt/ --breed=redhat --arch=x86_64

Finish with a cobbler sync:

cobbler sync

Import ARM based Operating Systems

Pull the vmlinuz and initrd from:

Add the ARM kernel and ramdisk image to the cobbler system

  cobbler distro add --name=ubuntu1204-armhf --kernel=/var/lib/tftpboot/images.bak/ubuntu1204-armhf/vmlinuz --initrd=/var/lib/tftpboot/images.bak/ubuntu1204-armhf/initrd.gz
  cobbler profile add --name=ubuntu1204-armhf --distro=ubuntu1204-armhf

Change the boot args:

  cobbler profile edit --name ubuntu1204-armhf --kopts="console=ttyAMA0 priority=critical text auto=true netcfg/choose_interface=eth0 url=http://172.28.0.2/cblr/svc/op/ks/profile/ubuntu1204-armhf"
  # Verify them:
  cobbler profile report --name ubuntu1204-armhf

Add an ARM system to cobbler:

  # Note: use cxmange to get all the MAC address then add MACs to cobbler system
  cobbler system add --name=calx1 --profile=ubuntu1204-armhf --mac=fc:2f:40:c6:e8:64 --ip-address=172.28.10.1 --hostname=calx1 --dns-name=calx1.pxe.boston.co.uk

Sample of the Ubuntu NQA (No Questions Asked) preseed file

 Ubuntu Server Quick Install
# by Dustin Kirkland <kirkland@ubuntu.com>
#  * Documentation: http://bit.ly/uquick-doc

d-i     debian-installer/locale string en_US.UTF-8
d-i     debian-installer/splash boolean false
d-i     console-setup/ask_detect        boolean false
d-i     console-setup/layoutcode        string us
d-i     console-setup/variantcode       string
d-i     netcfg/get_nameservers  string
d-i     netcfg/get_ipaddress    string
d-i     netcfg/get_netmask      string 255.255.255.0
d-i     netcfg/get_gateway      string
d-i     netcfg/confirm_static   boolean true
d-i     mirror/country string manual
d-i     mirror/http/hostname string ports.ubuntu.com
d-i     mirror/http/directory string /ubuntu-ports
d-i     clock-setup/utc boolean true
d-i     partman-auto/method string regular
d-i     partman-lvm/device_remove_lvm boolean true
d-i     partman-lvm/confirm boolean true
d-i     partman/confirm_write_new_label boolean true
d-i     partman/choose_partition        select Finish partitioning and write changes to disk
d-i     partman/confirm boolean true
d-i     partman/confirm_nooverwrite boolean true
d-i     partman/default_filesystem string ext3
d-i     clock-setup/utc boolean true
d-i     clock-setup/ntp boolean true
d-i     clock-setup/ntp-server  string ntp.ubuntu.com
d-i     base-installer/kernel/image     string linux-server
d-i     passwd/root-login       boolean false
d-i     passwd/make-user        boolean true
d-i     passwd/user-fullname    string ubuntu
d-i     passwd/username string ubuntu
# password: ubuntu
d-i     passwd/user-password-crypted    password $6$.1eHH0iY$ArGzKX2YeQ3G6U.mlOO3A.NaL22Ewgz8Fi4qqz.Ns7EMKjEJRIW2Pm/TikDptZpuu7I92frytmk5YeL.9fRY4.
d-i     passwd/user-uid string 
d-i     user-setup/allow-password-weak  boolean false
d-i     user-setup/encrypt-home boolean false
d-i     passwd/user-default-groups      string adm cdrom dialout lpadmin plugdev sambashare
d-i     apt-setup/services-select       multiselect security
d-i     apt-setup/security_host string security.ubuntu.com
d-i     apt-setup/security_path string /ubuntu
d-i     debian-installer/allow_unauthenticated  string false
d-i     pkgsel/upgrade  select safe-upgrade
d-i     pkgsel/language-packs   multiselect 
d-i     pkgsel/update-policy    select none
d-i     pkgsel/updatedb boolean true
d-i     grub-installer/skip     boolean false
d-i     lilo-installer/skip     boolean false
d-i     grub-installer/only_debian      boolean true
d-i     grub-installer/with_other_os    boolean true
d-i     finish-install/keep-consoles    boolean false
d-i     finish-install/reboot_in_progress       note 
d-i     cdrom-detect/eject      boolean true
d-i     debian-installer/exit/halt      boolean false
d-i     debian-installer/exit/poweroff  boolean false
d-i     pkgsel/include string openssh-server puppet curl
byobu   byobu/launch-by-default boolean false

Sample of Ubuntu preseed file which uses a custom partition scheme and XFS (details obtained from http://cptyesterday.wordpress.com/2012/06/17/notes-on-using-expert_recipe-in-debianubuntu-preseed-files/):

# Ubuntu Server Quick Install
# by Dustin Kirkland <kirkland@ubuntu.com>
#  * Documentation: http://bit.ly/uquick-doc

d-i     debian-installer/locale string en_US.UTF-8
d-i     debian-installer/splash boolean false
d-i     console-setup/ask_detect        boolean false
d-i     console-setup/layoutcode        string us
d-i     console-setup/variantcode       string
d-i     netcfg/get_nameservers  string
d-i     netcfg/get_ipaddress    string
d-i     netcfg/get_netmask      string 255.255.255.0
d-i     netcfg/get_gateway      string
d-i     netcfg/confirm_static   boolean true
d-i	mirror/country string manual
d-i	mirror/http/hostname string 172.28.0.2
d-i	mirror/http/directory string /ubuntu-ports
d-i     clock-setup/utc boolean true
d-i 	partman-auto/disk string /dev/sda
d-i 	partman-auto/method string regular
d-i 	partman-auto/expert_recipe string root :: 			\
	300 10 300 ext3 						\
        	$primary{ } $bootable{ } method{ format }		\
        	format{ } use_filesystem{ } filesystem{ ext3 } 		\
        	mountpoint{ /boot } 					\
    	. 								\
    	2048 20 8192 linux-swap 					\
        	$primary{ } method{ swap } format{ } 			\
    	. 								\
    	100 30 10000000000 xfs 						\
        	$primary{ } method{ format } format{ } 			\
        	use_filesystem{ } filesystem{ xfs } 			\
        	mountpoint{ / } 					\
    	.
d-i 	partman-auto/choose_recipe select root
d-i 	partman-partitioning/confirm_write_new_label boolean true
d-i 	partman/choose_partition select Finish partitioning and write changes to disk
d-i 	partman/confirm boolean true
d-i     clock-setup/utc boolean true
d-i     clock-setup/ntp boolean true
d-i     clock-setup/ntp-server  string ntp.ubuntu.com
d-i     base-installer/kernel/image     string linux-server
d-i     passwd/root-login       boolean false
d-i     passwd/make-user        boolean true
d-i     passwd/user-fullname    string ubuntu
d-i     passwd/username string ubuntu
d-i     passwd/user-password-crypted    password $6$.1eHH0iY$ArGzKX2YeQ3G6U.mlOO3A.NaL22Ewgz8Fi4qqz.Ns7EMKjEJRIW2Pm/TikDptZpuu7I92frytmk5YeL.9fRY4.
d-i     passwd/user-uid string
d-i     user-setup/allow-password-weak  boolean false
d-i     user-setup/encrypt-home boolean false
d-i     passwd/user-default-groups      string adm cdrom dialout lpadmin plugdev sambashare
d-i     apt-setup/services-select       multiselect security
d-i     apt-setup/security_host string security.ubuntu.com
d-i     apt-setup/security_path string /ubuntu
d-i     debian-installer/allow_unauthenticated  string true
d-i     pkgsel/upgrade  select safe-upgrade
d-i     pkgsel/language-packs   multiselect
d-i     pkgsel/update-policy    select none
d-i     pkgsel/updatedb boolean true
d-i     grub-installer/skip     boolean false
d-i     lilo-installer/skip     boolean false
d-i     grub-installer/only_debian      boolean true
d-i     grub-installer/with_other_os    boolean true
d-i     finish-install/keep-consoles    boolean false
d-i     finish-install/reboot_in_progress       note
d-i     cdrom-detect/eject      boolean true
d-i     debian-installer/exit/halt      boolean false
d-i     debian-installer/exit/poweroff  boolean false
d-i     pkgsel/include string openssh-server puppet curl
d-i     preseed/late_command string chroot /target sh -c "/usr/bin/curl -o /tmp/postinstall http://172.28.0.2/cobbler/ks_mirror/seeds/postinstall_puppet && /bin/sh -x /tmp/postinstall"
#d-i     preseed/late_command string true && \
#        \$SNIPPET('boston_test') \
#        true
#d-i     preseed/late_command string in-target 'pwd ; ls ; cd /root ; wget http://172.28.0.2/cobbler/ks_mirror/seeds/arm_late_stage.sh ; chmod +x arm_late_stage.sh ; ./arm_late_stage.sh'
byobu   byobu/launch-by-default boolean false

Display available profiles

Display the available profiles used for installations. This is basically the same as seen on the PXE boot menu

root@ubuntu1204-cobbler:~# cobbler profile list
   CentOS_6.3_X86_64-x86_64
   centos57-x86_64
   centos57-xen-x86_64
   centos62-x86_64
   centos63-x86_64
   fedora17-armhf
   rhel62-x86_64
   rhel62-x86_64_PCM
   ubuntu1204-armhf
   ubuntu1204-server-x86_64
   ubuntu1210-armhf

Change the installation settings

View the profile (which will include kickstart files)

root@ubuntu1204-cobbler:~$ cobbler profile report --name=centos62-x86_64
<snip>
Kickstart                      : /var/lib/cobbler/kickstarts/sample.ks
</snip>

Change the kickstart file

cobbler profile edit --name=centos62-x86_64 --kickstart=/var/lib/cobbler/kickstarts/kickstart-sdaonly.ks

Add a repo mirror to cobbler

root@pxe:~# cobbler repo add --name=EPEL-x86_64 --mirror=http://download.fedoraproject.org/pub/epel/6/x86_64 --mirror-locally=0


You then need to create an appropriate directory for this repo to exist (cobbler will decide upon a default directory but won't create it). For example:

root@pxe:~# mkdir /var/www/cobbler/repo_mirror/EPEL-x86_64


Then run a cobbler reposync:

root@pxe:~# cobbler reposync
task started: 2014-11-27_123446_reposync
task started (id=Reposync, time=Thu Nov 27 12:34:46 2014)
hello, reposync
run, reposync, run!
running: /usr/bin/wget -q http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/repomd.xml -O /var/www/cobbler/repo_mirror/EPEL-x86_64/.origin/repomd.xml
received on stdout: 
received on stderr: 
running: /usr/bin/wget -q http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/a61828faf0beb5ca73e9a5c2cd5294be3ac147a311041aed2bda39b530328846-comps-el6.xml -O /var/www/cobbler/repo_mirror/EPEL-x86_64/repodata/a61828faf0beb5ca73e9a5c2cd5294be3ac147a311041aed2bda39b530328846-comps-el6.xml
received on stdout: 
received on stderr: 
running: /usr/bin/wget -q http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/b7dfeeb47e3c60f9510dc99f3e38ab42e8e8030458160cfabf111072295dfdb6-updateinfo.xml.gz -O /var/www/cobbler/repo_mirror/EPEL-x86_64/repodata/b7dfeeb47e3c60f9510dc99f3e38ab42e8e8030458160cfabf111072295dfdb6-updateinfo.xml.gz
received on stdout: 
received on stderr: 
running: /usr/bin/wget -q http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/a28e7053cdd302f563a541eb4fb1a0cbd6442787c5a9a968fe0f550e35ad7ff8-comps-el6.xml.gz -O /var/www/cobbler/repo_mirror/EPEL-x86_64/repodata/a28e7053cdd302f563a541eb4fb1a0cbd6442787c5a9a968fe0f550e35ad7ff8-comps-el6.xml.gz
received on stdout: 
received on stderr: 
running: /usr/bin/wget -q http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/358cbe9abce14fa5e06d554032a83302e76198ebda9ca6f40017359eac79d32c-pkgtags.sqlite.gz -O /var/www/cobbler/repo_mirror/EPEL-x86_64/repodata/358cbe9abce14fa5e06d554032a83302e76198ebda9ca6f40017359eac79d32c-pkgtags.sqlite.gz
received on stdout: 
received on stderr: 
creating: /var/www/cobbler/repo_mirror/EPEL-x86_64/config.repo
running: chown -R root:www-data /var/www/cobbler/repo_mirror/EPEL-x86_64
received on stdout: 
received on stderr: 
running: chmod -R 755 /var/www/cobbler/repo_mirror/EPEL-x86_64
received on stdout: 
received on stderr: 
*** TASK COMPLETE ***

Attach a local repo to a cobbler profile

cobbler profile edit --name=SLC6.5-compute-x86_64 --repos="EPEL-x86_64"


Check the rendered kickstart file and you should see the new repo listed. In this example, the URL was http://172.28.0.2/cblr/svc/op/ks/profile/SLC6.5-compute-x86_64.

# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard uk
# System language
lang en_US
# Use network installation
url --url=http://172.28.0.2/cblr/links/SLC6.5-compute-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=EPEL-x86_64 --baseurl=http://download.fedoraproject.org/pub/epel/6/x86_64 # <-- Here it is!
repo --name=source-1 --baseurl=http://172.28.0.2/cobbler/ks_mirror/SLC6.5-x86_64-compute-x86_64
repo --name=source-2 --baseurl=http://172.28.0.2/cobbler/ks_mirror/SLC6.5-x86_64-compute-x86_64/SLC

Add unmanaged DNS entry

Edit the file: /etc/cobbler/zone.template

puppet IN A 172.28.0.2

$host_record

Cobbler sync once the changes have been made

Cobbler Commands

  • Show the system settings for an installed systems
  • Change profile (image) and MAC
$ cobbler system report --name blade8
$ cobbler system edit --name=blade8 --profile=CentOS_6.5_X86_64-x86_64 --mac-address=00:25:90:95:30:EA
$ cobbler sync

Post Install script

A post install script can be called as soon as installation has completed. The above preseed file has this script called in the following line:

d-i     preseed/late_command string chroot /target sh -c "/usr/bin/curl -o /tmp/postinstall http://172.28.0.2/cobbler/ks_mirror/postinstall_puppet && /bin/sh -x /tmp/postinstall"

The actual file location is: /var/lib/cobbler/webroot/cobbler/ks_mirror and is linked to /var/www/cobbler/webroot/cobbler/ks_mirror

The file contents can be:

#!/bin/sh 
CURL=/usr/bin/curl 
${CURL} -o /etc/puppet/puppet.conf http://172.28.0.2/cobbler/ks_mirror/puppet.conf 
${CURL} -o /etc/default/puppet http://172.28.0.2/cobbler/ks_mirror/default-puppet
puppet agent --enable