Capistrano

5,451 views

Published on

Using capistrano for system administration

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,451
On SlideShare
0
From Embeds
0
Number of Embeds
46
Actions
Shares
0
Downloads
48
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Capistrano

  1. 1. Capistrano for System Administrators (not rails developers) Bryan McLellan http://loftninjas.org btm@loftninjas.org Senior Systems Administrator Widemile
  2. 2. Landing Page Optimization (LPO) by way of Secret Sauce with new SaaS Partner Platform Front end F5 VIP Cluster F5 VIP Cluster
  3. 3. Landing Page Optimization (LPO) by way of Secret Sauce with new SaaS Partner Platform Debian Host Blades w/VMware Server Front end Debian Guests Debian Guests F5 VIP Cluster F5 VIP Cluster w/Apace fronted w/Apace fronted JBoss Clusters JBoss Clusters Debian Guests Debian Guests w/Apace fronted w/Apace fronted JBoss Clusters JBoss Clusters
  4. 4. Landing Page Optimization (LPO) by way of Secret Sauce with new SaaS Partner Platform Debian Host Blades w/VMware Server Front end Debian Guests Debian Guests F5 VIP Cluster F5 VIP Cluster w/Apace fronted w/Apace fronted JBoss Clusters JBoss Clusters Database Backend Debian Guests Debian Guests w/Apace fronted w/Apace fronted MSSQL Cluster MSSQL Cluster JBoss Clusters JBoss Clusters
  5. 5. Capistrano is Puppet for the Rails community
  6. 6. Not Invented Here ? http://www.flickr.com/photos/evdg/150116781/ http://www.flickr.com/photos/junewess/2111679056/
  7. 7. Not Invented Here Who is your daddy, and what does he do? Puppet Capistrano • Ruby / Ruby-ish • Ruby / Ruby-ish • Written by a Systems Administrator • Written by a Rails Developer • Luke Kanies – Reductive Labs • Jamis Buck – 37signals • Designed to manage server configuration • Designed to deploy web applications http://www.madstop.com/ http://weblog.jamisbuck.org/ http://en.wikipedia.org/wiki/Puppet http://en.wikipedia.org/wiki/Capistrano http://reductivelabs.com/projects/puppet/ http://www.capify.org/
  8. 8. 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.
  9. 9. Installing Capistrano 1. Install ruby 2. Install ruby gems 3. gem install capistrano Wait, what’s a GEM? Yet another package manager
  10. 10. Not Invented Here ? http://www.flickr.com/photos/evdg/150116781/ http://www.flickr.com/photos/junewess/2111679056/
  11. 11. Not Invented Here Not 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
  12. 12. Building a Capistrano deb 1. apt-get install build-essential fakeroot ruby-pkg-tools 2. 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.tgz 4. tar -xvzf capistrano-2.2.0.tgz 5. mv trunk/* capistrano-2.2.0/ 6. cd capistrano-2.2.0/ 7. dch –v2.2.0 8. dpkg-buildpackage –rfakeroot 1. cd .. 2. sudo dpkg -i capistrano_2.1.0-1_all.deb 3. apt-get install -f http://git.ninjr.org/?p=code.git;a=tree;f=debian/capistrano http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=428879 http://svn.debian.org/wsvn/pkg-ruby-extras/packages-wip/capistrano/trunk
  13. 13. fastthread who? $ cap –V You 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=472702 This is fixed in ruby1.8 >= 1.8.6 p110 (1.8.6.111-2ubuntu1.1), no worries.
  14. 14. Using Capistrano invoke Assumptions: • 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=quot;ots01, ots02, ots03quot; COMMAND=quot;whoamiquot; invoke * executing `invoke‘ * executing quot;whoami“ servers: [quot;ots01quot;, quot;ots02quot;, quot;ots03quot;] [ots01] executing command [ots02] executing command [ots03] executing command ** [out :: ots01] bryanm ** [out :: ots02] bryanm ** [out :: ots03] bryanm command finished
  15. 15. Why use Capistrano when we have Puppet? Heard during a Capistrano talk at OSCON • Restart a particular service on multiple servers once $ cap HOSTS=quot;ots01, ots02, ots03quot; COMMAND=“/etc/init.d/apache2 restartquot; invoke • Check the state of a service or resource (memory, cpu) that isn’t monitored $ cap HOSTS=quot;ots01, ots02, ots03quot; COMMAND=quot;grep MemTotal /proc/meminfoquot; invoke • Run a command on multiple servers AND monitor it’s output $ cap HOSTS=quot;ots01, ots02, ots03quot; COMMAND=“tail –f /var/log/apache2/error.logquot; invoke • Systems deployment tasks: install puppet, build VMs, etc. $ cap -S recipe=debian_client -S client=newbox01 build
  16. 16. Using Capistrano shell $ cap HOSTS=quot;ots01, ots02, ots03quot; 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
  17. 17. Using Capistrano shell Sure, but I can do that with ClusterSSH, right? How about on fifty hosts? Programmatically? $ cap -S recipe=iclassify -S query=quot;tag:ots-serverquot; COMMAND=quot;/etc/init.d/apache2 restartquot; SUDO=1 invoke $ cap -S recipe=iclassify -S query=quot;tag:workstationquot; puppet https://wiki.hjksolutions.com/display/IC/Capistrano+Task
  18. 18. http://loftninjas.org “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.)” Andrew Shafer – Reductive Labs http://stochasticresonance.wordpress.com

×