codefest 2013. mosesohn m. — automating environments with cobbler

40
Cobbler for Developers Matthew Mosesohn Mirantis IT

Upload: codefest

Post on 11-May-2015

422 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Cobbler forDevelopers

Matthew MosesohnMirantis IT

Page 2: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Developers? Uniformity?

Page 3: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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.

Page 4: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Why Cobbler?

● Simple web UI and command line● Robust template interface via Cheetah● Built to save time● Open source● Mature

Page 5: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Cobbler history

Developed by DevOps engineer Michael DeHaan (former Red Hat employee)Primary goal to simplify installationSoftware environments require frequent reinstallations

Page 6: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 7: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 8: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

When Cobbler is not appropriate

Scenarios:● Simple application development● Legacy system development● Where automation is not possible● Windows

Page 9: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Continuous Integration

Overview:● High pace development style● Automated deployment● Integrate and test software● Test every commit● Similar to production environment

Page 10: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Continuous Integration

Advantages:● Saves time and money● Enables sophisticated QA● Early warning of bugs● Communication● Develops metrics for analysis

Page 11: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Continuous Integration

Disadvantages:● Setup time investment● Full automation development

Page 12: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 13: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 14: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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)

Page 15: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Considerations

Scale:● How many sites● Concurrent installations● Number of systemsComplexity:● Linux distros● System builds● Localization● Post-installation scripts

Page 16: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 17: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Common use case: Development lab

Cobbler server

Internet:OS filespackage

repositories

OS filespackages

Systemconfiguration

Development Lab

System1 System2

System3 System4

System5 System6

Page 18: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Unattended install script

Page 19: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Create kickstart file

● Set up install method● Configure disks● Configure language/keyboard/time● Configure default package set● Specify scripts in %post for automation

Page 20: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Example kickstart for installationinstallreboot

lang en_USnetwork --bootproto=dhcpkeyboard us

clearpart --allpart / --size 500 --growpart swap --recommended

#set timezonetimezone --utc US/Eastern

Page 21: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Example kickstart for installation#set root passwordrootpw changeme#rootpw --iscrypted $1$Rig3dbXb$OWcv00J/V2WsBGcgx0bmp1

%packages@baseopenssh-serveropenssh-client

%post#Your script here

Page 22: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 23: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 24: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 25: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Debian/Ubuntu (cont'd)d-i preseed/early_command string your_pre_installation_script

d-i preseed/late_command string your_post_installation_script

Page 26: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Preinstallation script

● Useful for a disclaimer, warning, or safety message.

● Disk configuration manual steps

Page 27: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Postinstallation script

● Custom downloaded files/settings/scripts● Enable configuration management● Set up SSH keys● Custom authentication if not possible

through preseed/kickstart

Page 28: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 29: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Working with variables

cobbler system dumpvars --name=system

Built-in variables:● $mac_address

● $ip_address

● $hostname

● $distro

● $profile

● $server

Page 30: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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')

Page 31: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Adding systems to Cobbler

Page 32: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Add your distro

● Download base OS media● mount -oloop /mnt/iso /path/to/os.iso● cobbler import --path /mnt/iso --

name=distro_name

Page 33: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Adding profiles to Cobbler

● Log into Cobbler Web

● Add new profile with your distro and kickstart

Page 34: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 35: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

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

Page 36: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Further automation

PuppetSquid proxyJenkinsContinuous integration

Page 37: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Known limitations

Ubuntu installation works, but there are some issues with virt-install for Ubuntu guestsScaling and redundancy

Page 38: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Summary

● Cobbler allows you to automate installations● Cobbler fits into CI testing● Cobbler saves time● Cobbler is extendable via Cheetah template

engine

Page 39: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

Questions?Thank you!

Page 40: CodeFest 2013. Mosesohn M. — Automating environments with Cobbler

https://www.redhat.com/about/news/archive/2008/4/provisioning-our-new-middleware-architecturehttps://github.com/cobbler

Additional reading