4. ~WHOAMI
• Jose Diaz-Gonzalez
• Resident IRC Troll (savant)
• Rants at http://josediazgonzalez.com
➘
• Harasses as @savant
me
• Codes as josegonzalez on github
• EMPLOYED at @seatgeek
not me
➘
I’m also hot like sriracha sauce
5. WHO IS THIS TALK FOR?
• Devs/Sysadmins not afraid of Ruby
• Developers who don’t have time to waste with sysops
• Sysadmins who are looking to automate more of their
workflow
Also anyone who couldn’t get into Mark’s talk
6. WHY AM I SPEAKING ABOUT
THIS?
• I’m no Sysadmin; Sysadmining on half of the projects I’m on
• Devs do servers wrong; Perhaps I do too
• PHPNut Parole Policy (PPP)
My Crime: The Patriot Ale House
7. WHAT THE HELL IS THIS
• Being lazy
• Deploying a SERVAR
• CHARGING LAYSHURS
• What about the app?
¡¡¡SHOOP DA WOOP!!!
9. # Every policy must have a bundlesequence • Geared towards automated
body common control deployments of workstations, not
{ servers
bundlesequence => { "test" };
inputs => { "cfengine_stdlib.cf" }; • Convergence implies we may never
} be within compliance
bundle agent test
{ • Community maintained packages?
files:
# This is a throw‐away comment, below is a full‐bodied promise
"/tmp/testfile" # promiser
comment => "This is for keeps...", # Live comment
create => "true", # Constraint 1
perms => m("612"); # Constraint 2, rw‐‐‐x‐
w‐
}
I love it when an automation tool makes a promise
14. WHY CHEF?
• Uses a Ruby DSL; Doesn’t • All
the cool rails developers
re-invent the wheel are using it
• Officially-sanctioned • Awesome logo
Cookbooks
• Screams when things are
• Community-supported broken
Cookbooks
• Extensive Documentation
And the obvious Chef/CakePHP pun
15. HOW IS DEPLOYMENT FORMED?
• Each server can have one or more cookbooks
• Cookbooks are like plugins (nginx, apache, memcache) that
can depend upon/require one another
• Cookbooks have recipes, libraries, templates, definitions, files
• Recipes are sets of instructions
I vote we rename “plugins” to “recipes”
16. WHAT’S IN A RESOURCE CALL?
resource special node var name of resource
➘
➘
➘
git "#{node[:server][:production][:dir]}/#{hostname}/#{base}/public" do
repository info[:repository]
user "deploy"
group "deploy"
end ➘
options
http://wiki.opscode.com/display/chef/Resources
17. ROLL YOUR OWN
RESOURCES?
Yo dawg, I hurd u liek yo yos so I gave yo dawg
a yo yo so yo dawg can yo yo while yo dawg yo
yos yo dawg yo
18. Resources on the Cheap
# Definition
define :nginx_up, :enable => true do
template params[:name] do
source "html.erb"
owner "deploy" ➘
Just chain resources
group "deploy"
mode 0644
variables(params[:variables])
end
nginx_site params[:hostname] do
action :enable
Fire at will
end
➘
end
# Usage
nginx_up "#{node[:nginx][:dir]}/sites‐available/#{hostname}.#{base}" do
hostname "#{info[:hostname]}.#{info[:base]}"
variables(info[:variables])
end
“Fake” resources, for more info see http://wiki.opscode.com/display/chef/Providers
23. SERVER DNA
• An instance is defined as a JSON DNA file
• dna.json reference both recipes and configurations
• Modifying DNA should reconfigure server
• DNA can be versioned with the app
You too can be a Geneticist
24. BACK TO CAKE?
• Defineone set of • Automateserver
cookbooks, use everywhere deployment:
• Share, collaborate, grow • server new 127.0.0.1 lb.json
optimized server cookbooks
• CakePHP http://bit.ly/cakechef
• Define servers in terms of
DNA files: lb.json, db.json,
web.json, etc.
Contributions welcome, documentation being fleshed out
30. ANT
I’ll cut you
So I put some RDFA in your XML so you can SPARQL while you parse
31. 23 DEPLOYMENT TOOLS
LATER
It’s like deployment tools are project management software, sheesh
32. CAPISTRANO
• MOAR Ruby • Easy
to extend and
manipulate
• Similar
in concept to Chef -
has deployment strategies • Docs
are a bit hazy at the
moment
• Separates related tasks into
namespaces (deploy, • Geared towards SCM users
migration, etc.)
http://capistranorb.com
33. INSTALL
• Install Ruby/RubyGems
• gem install capistrano
• cd path/to/local/app/repository
• capify .
the other 8 steps of the process involve alcohol
34. CAPIFY?
• “capify .” creates a Capfile and a config/deploy.rb file
• deploy.rbis by convention; we can move the contents to the
Capfile if it bothers you
• Capfile is necessary and proper; loads capistrano plugins
35. deploy.rb
milliondollarapp.com
➘ <3 Perforce
➘
set :application, "set your application name here"
set :repository, "set your repository location here"
set :scm, :subversion
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, “your web‐server here” # Your HTTP server, Apache/etc
role :app, “your app‐server here” # This may be the same as your `Web` server
role :db, “your primary db‐server here”, :primary => true # This is where Rails migrations will run
role :db, “your slave db‐server here”
➘
➘
CakePHP is cool too
Cause we’re all on failover servers, right?
36. CUSTOMIZABLE
• Set your own SCM, deploy paths, even callbacks
• Define custom namespaces and tasks
• Override core functionality
40. CAVEATS
• Path to Cake Core may be incorrect - use -app flag
• Takes some initial setup
• Behaves funky with multiple concurrent deploys
• Potentially slow with large deploys
• Will
murder your datacenter if deploying to hundreds of
servers
41. CLAP
Props to Michael D’Auria, Sysadmin extraordinaire