2. Me?
Ken Robertson
Senior Software Engineer at Involver
Involver builds a social media marketing platform
Specialize in our platform’s reliability,
performance, and scalability
3. Our Chef Usage
10 separate environments
120+ servers
All managed with Chef
One Operations Engineer, Two Developers
4. What is Chef?
Server management and configuration in Ruby
Developed by OpsCode
Adopted by Engine Yard, 37signals, and more
Apache License
34. Definitions
for db in node[:mysql][:databases] do
mysql_database db[:name] do
root_user node[:mysql][:root_user] || 'root'
root_password node[:mysql][:root_password]
dbuser db[:user] || db[:name]
dbpassword db[:password]
end
end
35. Definitions
define :mysql_database do
execute "mysql-create-database" do
...
action :nothing
end
template "/tmp/mysql-#{params[:name]}.sql" do
source "create-database.sql.erb"
variables(:params => params)
notifies :run,
"execute[mysql-create-database]",
:immediately
end
end
36. Definitions
define :nginx_site do
include_recipe "nginx"
template "/etc/nginx/apps/#{params[:name]}.conf" do
source "#{params[:name]}.nginx.erb"
owner node[:user]
group node[:user]
mode 0644
variables(
:stage => params[:stage],
:name => params[:name]
)
notifies :reload, "service[nginx]", :delayed
end
end
38. Idempotency
execute "install-jruby" do
command %Q{
curl http://urlto/#{version}/jruby-src-#{version}.tar.gz -O &&
tar xvzf jruby-src-#{version}.tar.gz &&
pushd jruby-#{version} &&
ant &&
popd &&
mv jruby-#{version} /usr &&
rm jruby-src-#{version}.tar.gz &&
ln -snf /usr/jruby-#{version}/bin/jruby /usr/local/bin/jruby
}
creates "/usr/jruby-#{version}"
end
39. Idempotency - Fixed
execute "install-jruby" do
command %Q{
curl http://urlto/#{version}/jruby-src-#{version}.tar.gz -O &&
tar xvzf jruby-src-#{version}.tar.gz &&
pushd jruby-#{version} &&
ant &&
popd &&
mv jruby-#{version} /usr &&
rm jruby-src-#{version}.tar.gz
}
creates "/usr/jruby-#{version}/bin/jruby"
end
link "/usr/local/bin/jruby" do
to "/usr/jruby-#{version}/bin/jruby"
end