codefest 2013. mosesohn m. — automating environments with cobbler
TRANSCRIPT
Cobbler forDevelopers
Matthew MosesohnMirantis IT
Developers? Uniformity?
Why Cobbler?
Simple system to automate installation and preparation of systems.Reduces the amount of time needed to begin an installation.Provides a flexible, intuitive means to manage a large number of systems to meet your needs.
Why Cobbler?
● Simple web UI and command line● Robust template interface via Cheetah● Built to save time● Open source● Mature
Cobbler history
Developed by DevOps engineer Michael DeHaan (former Red Hat employee)Primary goal to simplify installationSoftware environments require frequent reinstallations
Manual network kickstart method
● Set up DHCP server to point to TFTP server● Configure TFTP with pxelinux.0 and
installation tree● Either handwrite MAC addresses for each
host or present a menu and manually choose
● No scaleability● No templating● No reporting
When do you need Cobbler?
Scenarios:● Complex software with many components● Testing clustering software● Testing software suites with no reset option
available● Continuous integration (CI) testing● Isolated network environment● Rapidly changing hardware
When Cobbler is not appropriate
Scenarios:● Simple application development● Legacy system development● Where automation is not possible● Windows
Continuous Integration
Overview:● High pace development style● Automated deployment● Integrate and test software● Test every commit● Similar to production environment
Continuous Integration
Advantages:● Saves time and money● Enables sophisticated QA● Early warning of bugs● Communication● Develops metrics for analysis
Continuous Integration
Disadvantages:● Setup time investment● Full automation development
CI example: Jenkins
Jenkins is a fork from HudsonJava basedSupports many SCM formats, including:● git● subversion● mercurial● cvsAutomate testing based on SCM changes or regular schedule
Typical Uses
● DNS/DHCP management of a company infrastructure
● Automation of installation of servers via PXE● Power cycling of systems via ipmitool● Local package repository mirror● Simplified, standard installation process
What you should know already
● How to build virtual machines● How to configure a DHCP server
○ hostnames○ MAC addresses○ gateway
● Where to find installation media for your system (DVD and/or package repositories)
Considerations
Scale:● How many sites● Concurrent installations● Number of systemsComplexity:● Linux distros● System builds● Localization● Post-installation scripts
Simple case: single node with virt
● Create a private virtual network
● Two VMs● VM 1 is CentOS● VM 2 is Ubuntu Linux host
Cobbler server
Internet:OS filespackage
repositories
OS filespackages
Systemconfigurati
on
VM 1
VM 2
Common use case: Development lab
Cobbler server
Internet:OS filespackage
repositories
OS filespackages
Systemconfiguration
Development Lab
System1 System2
System3 System4
System5 System6
Unattended install script
Create kickstart file
● Set up install method● Configure disks● Configure language/keyboard/time● Configure default package set● Specify scripts in %post for automation
Example kickstart for installationinstallreboot
lang en_USnetwork --bootproto=dhcpkeyboard us
clearpart --allpart / --size 500 --growpart swap --recommended
#set timezonetimezone --utc US/Eastern
Example kickstart for installation#set root passwordrootpw changeme#rootpw --iscrypted $1$Rig3dbXb$OWcv00J/V2WsBGcgx0bmp1
%packages@baseopenssh-serveropenssh-client
%post#Your script here
Debian/Ubuntu preseed file#Langd-i debian-installer/locale string en_GB.UTF-8d-i console-setup/ask_detect boolean falsed-i keyboard-configuration/layoutcode string us#Netd-i netcfg/enable boolean trued-i netcfg/get_hostname string system01d-i netcfg/get_domain string example.com
Debian/Ubuntu preseed file### Mirror settingsd-i mirror/country string russiad-i mirror/http/hostname string archive.ubuntu.comd-i mirror/http/directory string /ubuntu
d-i mirror/suite string precise
d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern
Debian/Ubuntu preseed file## Account setupd-i passwd/root-password-crypted password [MD5 hash]d-i passwd/user-fullname string Ubuntu Userd-i passwd/username string ubuntud-i passwd/user-password-crypted password [MD5 hash]
### Apt setupd-i apt-setup/restricted boolean trued-i apt-setup/universe boolean trued-i apt-setup/backports boolean truetasksel tasksel/first multiselect lamp-server, print-server
Debian/Ubuntu (cont'd)d-i preseed/early_command string your_pre_installation_script
d-i preseed/late_command string your_post_installation_script
Preinstallation script
● Useful for a disclaimer, warning, or safety message.
● Disk configuration manual steps
Postinstallation script
● Custom downloaded files/settings/scripts● Enable configuration management● Set up SSH keys● Custom authentication if not possible
through preseed/kickstart
Cobbler kickstart extra features
● You can store snippets and call them in multiple kickstarts
● You can use Cheetah template code directly in a kickstart (just prepend with '#'). Syntax similar to Python
Examples:%post$SNIPPET('ntp_register')
%packages#set $hostname = $getVar('$hostname', None)#if test in $hostname or devel in $hostname@development#end if
Working with variables
cobbler system dumpvars --name=system
Built-in variables:● $mac_address
● $ip_address
● $hostname
● $distro
● $profile
● $server
Flexibility with variables
● Set custom variables in ksmeta section.● Profile variables override distro variables.● System variables override profile variables.● Use getVar('var-name','default-value') in
cases where an empty string would break your installation○ RH: rootpw $getVar('rootpw','changeme')○ Deb: d-i passwd/root-password-crypted password $getVar
('rootmd5','$1$Rig3dbXb$OWcv00J/V2WsBGcgx0bmp1')
Adding systems to Cobbler
Add your distro
● Download base OS media● mount -oloop /mnt/iso /path/to/os.iso● cobbler import --path /mnt/iso --
name=distro_name
Adding profiles to Cobbler
● Log into Cobbler Web
● Add new profile with your distro and kickstart
Remote install options
● Manual entry of systems○ Requires MAC address
● PXE menu○ Requires manual interaction on boot
● koan/virt-install○ Create a virtual machine or reinstall existing system
and specify Cobbler server and profile to use
Koan examples
Reinstall a host:● koan --server=cobbler.example.org --
replace-self --profile=name
Create a new virtual machine:● koan --server=cobbler.example.org --virt --
system=name
Further automation
PuppetSquid proxyJenkinsContinuous integration
Known limitations
Ubuntu installation works, but there are some issues with virt-install for Ubuntu guestsScaling and redundancy
Summary
● Cobbler allows you to automate installations● Cobbler fits into CI testing● Cobbler saves time● Cobbler is extendable via Cheetah template
engine
Questions?Thank you!
https://www.redhat.com/about/news/archive/2008/4/provisioning-our-new-middleware-architecturehttps://github.com/cobbler
Additional reading