crapapult
Crapapult is a thin wrapper around Capistrano for the sole purpose of deploying services at Yammer.
What the hell is going on here
At Yammer, we use store all our deployable artifacts in a Maven repository. Each time we commit to a service, Jenkins runs all the tests and (if they pass, naturally) builds a fat, deployable JAR containing all the various dependencies which then gets deployed to our Nexus repository.
Crapapult allows us to deploy new versions of our services and synchronize those deploys with changes to application-specific configuration. (We use Puppet to provision and maintain machines with broad roles but use Crapapult to generate all the application-specific configuration.)
It does so by using Capistrano to SSH into each of the application servers and using curl
to
download the specified artifact from the Maven repo. This tends to be super-fast, especially if your
Maven repo is located in the same data center as your app servers.
Once the artifact is staged (by default in /opt/APPNAME
), it then uploads the specified set of
asset files to each server. After that, it renders and uploads the specified set of template files
to each server.
Then it restarts your service and gives you a high-five.
How to use this dang thing
Get yer install on:
gem install crapapult
Create yer dang deployer directory structure:
mkdir -p myapp-crapapult/{assets,templates}
cd myapp-crapapult
And start slingin' some crap in your Capfile
:
require "crapapult"
# Tell us where and what your application is.
maven "http://maven.example.com/repo/"
group_id "com.example.myapp"
artifact_id "myapp-service"
# Give your application a name.
application "myapp" do
# Upload the file in assets/myapp.jvm.conf to each host.
asset "myapp.jvm.conf", "/etc/myapp.jvm.conf"
# Render the ERB template in templates/myapp.conf.erb to each host.
template "myapp.conf.erb", "/etc/myapp.conf", :mode => "0600"
# Set up the file in assets/myapp.upstart as an Upstart config file and create
# an /etc/init.d/myapp script.
upstart "myapp.upstart"
end
# Define environments, optionally allowing snapshots.
environment :staging, :allow_snapshots => true do
# Set environment-specific data for your templates to work with.
data :jdbc_url, "jdbc:postgresql://db.example.com/happy_fun_times"
host "myapp-001.staging.example.com" do
# Set host-specific data for your templates to work with.
data :worker_id, "1"
end
end
# This will disallow deploying snapshots to production.
environment :production do
# Set environment-specific data for your templates to work with.
data :jdbc_url, "jdbc:postgresql://db.example.com/happy_fun_times"
host "myapp-001.example.com" do
# Set host-specific data for your templates to work with.
data :worker_id, "1"
end
host "myapp-002.example.com" do
data :worker_id, "2"
end
end
Deploying a thing
cap production # Deploy to the production environment
cap staging # Deploy to the staging environment
So to deploy to your staging environment, it's just a simple:
cap staging
You'll be prompted for the version you want to deploy (and, if you're deploying a snapshot, the build number), and you're off to the races.
Copyright (c) 2011 Yammer, Inc. See LICENSE.txt for further details.