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
Oxlintのカスタムルールの現況
syumai
6
1k
AIとRubyの静的型付け
ukin0k0
0
560
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
210
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
140
net-httpのHTTP/2対応について
naruse
0
470
CSC307 Lecture 17
javiergs
PRO
0
320
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.5k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
120
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
180
スマートグラスで並列バイブコーディング
hyshu
0
110
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
480
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
250
Featured
See All Featured
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
330
How GitHub (no longer) Works
holman
316
150k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
WENDY [Excerpt]
tessaabrams
11
38k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
770
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
Amusing Abliteration
ianozsvald
1
200
Paper Plane
katiecoart
PRO
1
51k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
380
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