capistrano, puppet, and chef

41
Capistrano, Puppet, and Chef Automating App Deployment & Config Management

Upload: david-benjamin

Post on 29-Jan-2018

17.743 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Capistrano, Puppet, and Chef

Capistrano, Puppet, and Chef

Automating App Deployment & Config Management

Page 2: Capistrano, Puppet, and Chef

These tools have to do with

• Application Deployment

• Configuration Management

These are different.

Discuss.

Page 3: Capistrano, Puppet, and Chef

In the beginning there was

scp : application deployment

ssh : configuration management

before things got complicated

Page 4: Capistrano, Puppet, and Chef

Let's talk about

Application Deployment

Page 5: Capistrano, Puppet, and Chef

simplest application deployment

1. scp app to production box.

2. Restart server. (optional)

3. Profit!

Page 6: Capistrano, Puppet, and Chef

But there are always complications, like

“unpack app into a particular directory”

“scrub lock files or workspace directories”

“run database upgrade/tweak scripts”

Page 7: Capistrano, Puppet, and Chef

These additional bits were usually done

a) by hand (ssh)

b) with deploy scripts living on the servers

c) or not done at all (oops!)

Page 8: Capistrano, Puppet, and Chef

Capistranowww.capify.org

Introduced around 2006 by Jamis Buck of 37Signals

written in Ruby, initally for Rails projects.

Page 9: Capistrano, Puppet, and Chef

Mainly because ruby on rails, particularly in production settings, had to use a ruby server called "mongrel" which was fast, but an absolute pain to restart. PAIN.

Page 10: Capistrano, Puppet, and Chef

Simplest Explanation

• Lets you to write scripts that say "ssh onto this machine and do this thing."

• You don't have to have magic scripts living on your servers, they can be source.

• You can start being clever, and programming your deployment actions.

Page 11: Capistrano, Puppet, and Chef

Simple "capfile" example

Page 12: Capistrano, Puppet, and Chef

Simple "capfile" with "roles", you get the idea

Page 13: Capistrano, Puppet, and Chef

Nice things Capistrano introduced:

Automate deploys with ONE set of files

The files DON’T have to live on the production server

The language (Ruby) allows some abstraction and finesse not available in blunt force shell scripting

Page 14: Capistrano, Puppet, and Chef

Now the application deployment step can be coded and tested like the rest of the project.

Page 15: Capistrano, Puppet, and Chef

And the deployment scripts can be strengthened, we all happy. Example:

Page 16: Capistrano, Puppet, and Chef

Unfortunately, Capistrano's future looks a little uncertain (in 2011). The project page redirects to a github page, which points to stale documentation. It seems widely used, but not well supported.

May be a bit like CruiseControl (the early awesome build server) the tool may have hit its "use by" date.

Not sure what the successor is. Vlad The Deployer? (http://rubyhitsquad.com/Vlad_the_Deployer.html)

Page 17: Capistrano, Puppet, and Chef

OK

Page 18: Capistrano, Puppet, and Chef

Let's talk about

Configuration Management

Page 19: Capistrano, Puppet, and Chef

This is where, on a new machine, you make sure

your apache's got mods

your ruby's got gems

your php's got pears

your java's got...version

All those things you remember, or forget, and then...

Page 20: Capistrano, Puppet, and Chef

This happens a lot:

One person knows how all the servers get configured. One awesome person.

or

Each server gets set up differently depending on who set them up. Awesomeness not a requirement. Medication helps.

and

Server setups are build by hand (ssh, ssh, ssh) from memory (or checklists written on forearms).

Page 21: Capistrano, Puppet, and Chef

This (sort of ) worked a little OK when servers were physical, so setting them up was a special magic ceremony.

Page 22: Capistrano, Puppet, and Chef

But when servers became virtual, the magic wore off, and the underlying dumbness shone through.

Page 23: Capistrano, Puppet, and Chef

Even for small projects, why can't we have:

• Configurations defined in source.

• Repeatable, consistent configs through test, stage, & production.

• Smart configurations that, say, enforce version levels and don't forget libraries.

Why?

Page 24: Capistrano, Puppet, and Chef

Puppet

http://www.puppetlabs.com

written in Ruby, evolved from cfengine

Page 25: Capistrano, Puppet, and Chef

"Puppet is typically (but not always) used in a client/server formation, with all of your clients talking to one or more central servers. Each client contacts the server periodically (every half hour, by default), downloads the latest configuration, and makes sure it is in sync with that configuration. Once done, the client can send a report back to the server indicating if anything needed to change."

Page 26: Capistrano, Puppet, and Chef

The server is called the "Puppet Master". Creepy, but cool.

Page 27: Capistrano, Puppet, and Chef

idempotent |ˈīdemˌpōtənt| Mathematics

adjective

denoting an element of a set that is unchanged in value when multiplied or otherwise operated on by itself.

noun

an element of this type.

ORIGIN late 19th cent.: from Latin idem ‘same’ + potent 1 .

The term can also be used to describe an initialisation subroutine that is arranged to perform some critical action exactly once, even if the routine is called several times.

[ Jargon File]

Page 28: Capistrano, Puppet, and Chef

Simple example of a Puppet class

class ntp { package { "ntp": ensure => installed } service { "ntp": ensure => running, }}

Page 29: Capistrano, Puppet, and Chef

Simple example of a node description

node myserver { include ntp}

This instructs puppet to make sure ntp is installed and running on "myserver"

(I left out the definition of "ntp" as a "resource". A big part of the Puppet DSL is a rich ability to define resources, their files, locations, permissions, just about everything about them.)

Page 30: Capistrano, Puppet, and Chef

Puppet manifests are declarative, as opposed to imperative.

The DSL is not Ruby, as you're not writing scripts, you're writing definitions.

Install order is determined through dependencies.

Page 31: Capistrano, Puppet, and Chef

And being idempotent, the puppet master will make sure the systems match the definitions.

This is kind of cool, in that you can implement changes across machines automatically just by updating the manifext in the puppet master.

Kind of scary, kind of cool.

Page 32: Capistrano, Puppet, and Chef

Chef

http://www.opscode.com/chef/

written in ruby, evolved from Puppet

Page 33: Capistrano, Puppet, and Chef

Chef is built around a chef server, which contains

• deployment scripts (called cookbooks and recipes)

• config instructions for machines (called nodes)

• security details for all (pem pem pem)

Page 34: Capistrano, Puppet, and Chef

You start with an empty machine

install enough stuff to run chef-client (ruby, chef)

and then run...chef-client

Page 35: Capistrano, Puppet, and Chef

As with Puppet, it is idempotent, so you can re-run it again and again to confirm or update config.

Chef recipes are imperitive, as opposed to declarative.

The DSL is extended Ruby, so you can write scripts, as well as definitions.

Install order is determined through script order, no dependency checking.

Page 36: Capistrano, Puppet, and Chef

Chef vs Puppet

(This appears to be a big debate, like we need that)

Page 37: Capistrano, Puppet, and Chef

“Chef vs. Puppet”

"Declarative" vs "Imperative"... oh, shoot me now.

(IMHO) Devs like Chef, because they can script it

(IMHO) Ops like Puppet, because its a set of rules

Both sides claim the other is "too complicated".

Go figure.

Page 38: Capistrano, Puppet, and Chef

What next?

There are a number of other tools in the space:

App Deploy: Capistrano, ControlTier, Fabric, Func, mCollective

SysConfig: Bcfg2, Chef, Puppet, cfengine, Smart Frog

Cloud/VM: Xen, Ixc, openVZ, Eucalyptus, KVM

OS Install: Kickstart, Jumpstart, Cobbler, OpenQRM, xCAT

Hard for them to get momentum & critical mass?

We may get further definition, hopefully simplification.

Page 39: Capistrano, Puppet, and Chef

Summing up

Application Deployment.

Configuration Management

Its nice to know these can be described in code, checked into source code control, tested, and then deployed.

I mean it is really nice!

Page 40: Capistrano, Puppet, and Chef

Questions?

Page 41: Capistrano, Puppet, and Chef

Thanks!