19
Capistrano for System Administrators (not rails developers) Bryan McLellan http://loftninjas.org [email protected] Senior Systems Administrator Widemile

Capistrano for System Administrators (not rails developers) Bryan McLellan [email protected] Senior Systems Administrator Widemile

Embed Size (px)

Citation preview

Capistrano forSystem Administrators

(not rails developers)

Bryan McLellanhttp://loftninjas.org [email protected]

Senior Systems AdministratorWidemile

Landing Page Optimization (LPO) by way of Secret Sauce with new

SaaS Partner Platform

Front end

F5 VIP Cluster F5 VIP Cluster

Landing Page Optimization (LPO) by way of Secret Sauce with new

SaaS Partner Platform

Debian Host Blades w/VMware Server

Debian Guests w/Apace fronted

JBoss Clusters

Front end

Debian Guests w/Apace fronted

JBoss Clusters

Debian Guests w/Apace fronted

JBoss Clusters

Debian Guests w/Apace fronted

JBoss Clusters

F5 VIP Cluster F5 VIP Cluster

Landing Page Optimization (LPO) by way of Secret Sauce with new

SaaS Partner Platform

Debian Host Blades w/VMware Server

Debian Guests w/Apace fronted

JBoss Clusters

Front end

Database Backend

Debian Guests w/Apace fronted

JBoss Clusters

Debian Guests w/Apace fronted

JBoss Clusters

Debian Guests w/Apace fronted

JBoss Clusters

F5 VIP Cluster F5 VIP Cluster

MSSQL Cluster MSSQL Cluster

Capistrano is Puppet for the Rails community

http://www.flickr.com/photos/junewess/2111679056/http://www.flickr.com/photos/evdg/150116781/

Not Invented Here

?

Not Invented Here

Puppet• Ruby / Ruby-ish• Written by a Systems Administrator• Luke Kanies – Reductive Labs• Designed to manage server configuration

http://www.madstop.com/http://en.wikipedia.org/wiki/Puppethttp://reductivelabs.com/projects/puppet/

Capistrano• Ruby / Ruby-ish• Written by a Rails Developer• Jamis Buck – 37signals• Designed to deploy web applications

http://weblog.jamisbuck.org/http://en.wikipedia.org/wiki/Capistranohttp://www.capify.org/

Who is your daddy, and what does he do?

Why use Capistrano when we have Puppet?Heard during a Capistrano talk at OSCON

• Restart a particular service on multiple servers once• Check the state of a service or resource (memory, cpu) that isn’t monitored• Run a command on multiple servers AND monitor it’s output• Systems deployment tasks: install puppet, build VMs, etc.

Installing Capistrano

1. Install ruby2. Install ruby gems3. gem install capistrano

Wait, what’s a GEM?Yet another package manager

http://www.flickr.com/photos/junewess/2111679056/http://www.flickr.com/photos/evdg/150116781/

Not Invented Here

?

Not Invented HereNot all package management systems are created equal.

Debian doesn’t need another package management system. We have our own, it works quite well, thank you.

http://pkg-ruby-extras.alioth.debian.org/rubygems.html

PLEASE do not install unpackaged software on production systems that someone else might have to inherit after your

very timely demise.

Also note that ‘gem update –system’ tends to break Debian/Ubuntu ruby installations, and is disabled in

libgems-ruby 1.0.0-1

Building a Capistrano deb1. apt-get install build-essential fakeroot ruby-pkg-tools2. svn checkout svn://svn.debian.org/pkg-ruby-extras/packages-wip/capistrano/trunk/3. wget http://rubyforge.org/frs/download.php/33072/capistrano-2.2.0.tgz4. tar -xvzf capistrano-2.2.0.tgz5. mv trunk/* capistrano-2.2.0/6. cd capistrano-2.2.0/7. dch –v2.2.08. dpkg-buildpackage –rfakeroot

9. cd ..10. sudo dpkg -i capistrano_2.1.0-1_all.deb11. apt-get install -f

http://git.ninjr.org/?p=code.git;a=tree;f=debian/capistranohttp://bugs.debian.org/cgi-bin/bugreport.cgi?bug=428879http://svn.debian.org/wsvn/pkg-ruby-extras/packages-wip/capistrano/trunk

fastthread who?$ cap –VYou are running Ruby 1.8.6, which has a bug in its

threading implementation. You are liable to encounter deadlocks running Capistrano, unless you install the fastthread library, which is available as a gem:

gem install fastthread

Wait, we’re installing a gem to fix a bug in ruby?

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472702This is fixed in ruby1.8 >= 1.8.6 p110 (1.8.6.111-2ubuntu1.1), no worries.

Using Capistrano invokeAssumptions:• You can access your servers via SSH

– There is some kind of proxy gateway functionality too

• You have the same password on all servers or PKI configured

$ cap HOSTS="ots01, ots02, ots03" COMMAND="whoami" invoke

* executing `invoke‘

* executing "whoami“

servers: ["ots01", "ots02", "ots03"]

[ots01] executing command

[ots02] executing command

[ots03] executing command

** [out :: ots01] bryanm

** [out :: ots02] bryanm

** [out :: ots03] bryanm

command finished

Why use Capistrano when we have Puppet?Heard during a Capistrano talk at OSCON

• Restart a particular service on multiple servers once$ cap HOSTS="ots01, ots02, ots03" COMMAND=“/etc/init.d/apache2 restart" invoke

• Check the state of a service or resource (memory, cpu) that isn’t monitored$ cap HOSTS="ots01, ots02, ots03" COMMAND="grep MemTotal /proc/meminfo" invoke

• Run a command on multiple servers AND monitor it’s output$ cap HOSTS="ots01, ots02, ots03" COMMAND=“tail –f /var/log/apache2/error.log" invoke

• Systems deployment tasks: install puppet, build VMs, etc.$ cap -S recipe=debian_client -S client=newbox01 build

Using Capistrano shell$ cap HOSTS="ots01, ots02, ots03" shell * executing `invoke‘

cap> ls

[establishing connection(s) to ots01, ots02, ots03]

cap> ps

** [out :: ots01] PID TTY TIME CMD

** [out :: ots01] 19437 ? 00:00:00 sshd

** [out :: ots01] 19445 ? 00:00:00 ps

** [out :: ots03] PID TTY TIME CMD

** [out :: ots03] 3222 ? 00:00:00 sshd

** [out :: ots03] 3231 ? 00:00:00 ps

** [out :: ots02] PID TTY TIME CMD

** [out :: ots02] 30751 ? 00:00:00 sshd

** [out :: ots02] 30756 ? 00:00:00 ps

Using Capistrano shellSure, but I can do that with ClusterSSH, right?

How about on fifty hosts? Programmatically?

$ cap -S recipe=iclassify -S query="tag:ots-server" COMMAND="/etc/init.d/apache2 restart" SUDO=1 invoke

$ cap -S recipe=iclassify -S query="tag:workstation" puppet

https://wiki.hjksolutions.com/display/IC/Capistrano+Task

http://loftninjas.org

Andrew Shafer – Reductive Labshttp://stochasticresonance.wordpress.com

“Parallel to the ‘Developer’ tribe in most organizations, often with a semi-antagonistic mutual dependence, there was always another tribe: ‘Sysadmin’. When Developers and Sysadmins got together, it sometimes felt like the dwarfs and high elves forced to work together by necessity. (I’ll let you workout which is which.)”