Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Application deployment with Chef
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Igor Afonov
November 22, 2012
Programming
1.1k
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Application deployment with Chef
Agile tour Riga 2012
Igor Afonov
November 22, 2012
More Decks by Igor Afonov
See All by Igor Afonov
Real-time application monitoring
iafonov
5
1k
Web servers - and how I created my own one
iafonov
8
1.2k
Chef - Infrastructure as code
iafonov
6
680
Other Decks in Programming
See All in Programming
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
160
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
270
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
200
Vite+ Unified Toolchain for the Web
naokihaba
0
340
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
610
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
7.9k
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.5k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
740
JavaDoc 再入門
nagise
1
420
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
560
Agentic UI
manfredsteyer
PRO
0
200
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
40k
How to build a perfect <img>
jonoalderson
1
5.7k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Rails Girls Zürich Keynote
gr2m
96
14k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
170
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Navigating Weather and Climate Data
rabernat
0
230
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
470
A Soul's Torment
seathinner
6
3k
Paper Plane
katiecoart
PRO
1
52k
Transcript
Application deployment with Chef Igor Afonov
‣ Ruby developer ‣ I’m participating in Chef development Developers
Sys Admins DevOps I’m here About Me
Configuration Management Chef Quick Intro Application Deployment FAQ Q &
A Agenda
Configuration Management
"Keep track of all the stuff you do to take
a system from 'bare metal' to 'doing its job'." - Adam Jacob
๏ Remember everything ๏ Keep notes in notepad ๏ Maintain
wiki ๏ Bash scripts ๏ Automation frameworks
Opscode Chef
๏ Configuration management framework ๏ Open source ๏ Created by
Adam Jacob ๏ Maintained by Opscode
๏ Client-server architecture ๏ Idempotence ๏ Declarative ๏ Ruby everywhere
Crash course
chef-server push pull VCS chef-client node chef-client node chef-client node
server chef repository developer Workflow
cookbook recipe chef-repository resource resource resource Code structure
Resource
package 'apache2' do action :install provider Chef::Provider::Package::Apt version '2.4' end
Cookbook File Cron Deploy Directory Env Execute* File Git Group
HTTP Request Ifconfig Link Log Mount Ohai Package PowerShell Script User Remote Directory Remote File Route Ruby Block SCM Script Service Subversion Template Bundled resources
Provider
package apt pacman macports Resource Providers Interface Implementation
service "redis" do action :start end Method call Parameter1 Parameter2
# lib/chef/platform.rb - Chef::Platform :macosx => { :default => { ... :package => Chef::Provider::Package::Macports, :service => Chef::Provider::Service::Macosx, ... } } # lib/chef/provider/service/macosx.rb class Chef::Provider::Service::Macosx < Chef::Provider::Service::Simple def start if @current_resource.running Chef::Log.debug("#{@new_resource} already running, not starting") else shell_out!("launchctl load -w '#{@plist}'") end end end
Recipe
package "postfix" do action :install end %w{main master}.each do |config|
template "/etc/postfix/#{config}.cf" do source "#{config}.cf.erb" owner "root" group "root" mode 0644 end end
Cookbook
cookbook |-attributes |-files |-libraries |-recipes |-templates |---metadata.rb
๏ Cookbooks should be data-driven ๏ Do not hardcode anything
๏ Control behavior via: ๏ Attributes ๏ Databags ๏ Search
Node
๏ Host that runs chef-client ๏ Has attributes ๏ Has
run list
Role
name "mail-server" description "Installs and configures postfix MTA" default_attributes :postfix
=> { "mydomain" => "domain.com", "myorigin" => "domain.com" } run_list "recipe[postfix]"
Chef repository
chef-repo |-cookbooks |-data_bags |-roles |-environments |---Rakefile https://github.com/opscode/chef-repo
chef-server push pull VCS chef-client node chef-client node chef-client node
server chef repository developer The big picture
๏ Authenticate node ๏ Synchronize cookbooks ๏ Compile ๏ Converge
chef-client run
๏ Resource is a unit of work ๏ Provider take
real action ๏ Recipe is collection of resources ๏ Cookbook is reusable set of recipes ๏ Code is pushed to chef-server ๏ Node pulls code from chef-server and runs it Recap
Deployment
๏ Get the code from VCS ๏ Put the code
to the right place ๏ Do some rituals Three easy* steps * Not true
Real-world example
internet nginx unicorn unicorn unicorn Simple Rails deployment
Get the code & put it to the right place
application 'copycopter' do repository '
[email protected]
:iafonov/copycopter-server.git' revision 'master' path '/var/www/apps/copycopter' end
Pick the SCM strategy application 'copycopter' do repository '
[email protected]
:iafonov/copycopter-server.git' revision
'master' path '/var/www/apps/copycopter' strategy :deploy_revision # :deploy_timestamped end
Set the code owner application 'copycopter' do repository '
[email protected]
:iafonov/copycopter-server.git' revision
'master' path '/var/www/apps/copycopter' strategy :deploy_revision owner 'deploy' group 'deploy' end
Install library dependencies application 'copycopter' do repository '
[email protected]
:iafonov/copycopter-server.git' revision 'master'
path '/var/www/apps/copycopter' strategy :deploy_revision owner 'deploy' group 'deploy' packages ['libxml2-dev', 'libxslt-dev'] end
Run migrations application 'copycopter' do repository '
[email protected]
:iafonov/copycopter-server.git' revision 'master' path
'/var/www/apps/copycopter' strategy :deploy_revision owner 'deploy' group 'deploy' packages ['libxml2-dev', 'libxslt-dev'] migrate true end
Restart service application 'copycopter' do repository '
[email protected]
:iafonov/copycopter-server.git' revision 'master' path
'/var/www/apps/copycopter' strategy :deploy_revision owner 'deploy' group 'deploy' packages ['libxml2-dev', 'libxslt-dev'] migrate true restart_command 'service copycopter restart' end
๏ rails ๏ java_webapp ๏ tomcat ๏ django ๏ ...
Sub-resources
Rails application 'copycopter' do ... rails do gems ['bundler'] database
do username node['mysql']['username'] password node['mysql']['password'] database 'copycopter_production' end end end
Unicorn application 'copycopter' do ... rails do ... end unicorn
do worker_processes 4 port 8080 end end
nginx application 'copycopter' do ... rails do ... end unicorn
do ... end nginx_load_balancer do static_files '/public' => 'public' application_server_role 'copycopter_app_server' end end
๏ before_deploy ๏ before_migrate ๏ before_symlink ๏ before_restart ๏ after_restart
Callbacks
Run backups application 'copycopter' do ... before_deploy do execute 'run_backups'
do command 'rsync ....' end end end
Notify monitoring system application 'copycopter' do ... before_deploy do execute
'run_backups' do command 'rsync ....' end end after_restart do StatsD.gauge("#{node.name}.deploy") end end
๏ Chef allows declaratively describe deploy process ๏ A lot
of technology stacks are supported via sub-resources ๏ You can precisely control each step of process Recap
FAQ
When you should automate your infrastructure?
Which tool should you use?
What are benefits of using automation tools?
Q & A
[email protected]
http://iafonov.github.com @iafonov
Thank You!
[email protected]
http://iafonov.github.com @iafonov