Copyright © 2010 Opscode, Inc - All Rights Reserved
Speaker:
‣ joshua@opscode.com
‣ @jtimberman
‣ www.opscode.com
Joshua T...
Copyright © 2010 Opscode, Inc - All Rights Reserved 2http://www.flickr.com/photos/anotherphotograph/2100904507/sizes/o/
Sys...
Copyright © 2010 Opscode, Inc - All Rights Reserved
http://www.flickr.com/photos/timyates/2854357446/sizes/l/
3
Rails Devel...
Copyright © 2010 Opscode, Inc - All Rights Reserved 4
Application Deployment
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved
Application Deployment
5
tar -x -C /app -f app.tar
rsync ~/dev/app www...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Server Configuration
6
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved
Server Configuration
Web Servers
Load Balancers
Database Servers
7
Thur...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Server Configuration
8
% vi /etc/mysql/my.cnf
#!/bin/bash
Capfile
Thursd...
Copyright © 2010 Opscode, Inc - All Rights Reserved 9http://www.brooklynstreetart.com/theBlog/wp-content/uploads/2008/12/s...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Chef Client runs on your
systems
10
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved
Clients talk to a Chef
Server
11
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved http://www.flickr.com/photos/peterrosbjerg/3913766224/ 12
We call each ...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Nodes have Attributes
13
{
"kernel": {
"machine": "x86_64",
"name": "D...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Nodes have a Run List
14
What Roles or Recipes to apply
in Order
Thurs...
Copyright © 2010 Opscode, Inc - All Rights Reserved 15http://www.flickr.com/photos/laenulfean/374398044/
Nodes have Roles
T...
Copyright © 2010 Opscode, Inc - All Rights Reservedhttp://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/ 16
Rec...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Chef manages
Resources on Nodes
17
cookbook_file
template
service
pack...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Data bags store
arbitrary data
18
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved
Nodes, Roles, Data
Bags are Searchable
19
% knife search node “role:we...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Application Deployment
20
Application Repository
‣ Source
‣ CI / Build...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Chef Repository
Roles
Cookbooks
Application Information
‣ Data Bag!
21...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Application Information
Data Bag
JSON
22
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved
Walkthrough
23
Thursday, November 18, 2010
Copyright © 2010 Opscode, Inc - All Rights Reserved 24
{
"id": "radiant",
"server_roles": [
"radiant"
],
"type": {
"radian...
Copyright © 2010 Opscode, Inc - All Rights Reserved 25
base.rb
production.rb
radiant.rb
radiant_database_master.rb
radiant...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Base Role
26
name "base"
description "Base role applied to all nodes."...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Production Role
27
name "production"
description "Nodes in the product...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Radiant Role
28
name "radiant"
description "radiant front end applicat...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Application Recipe
29
search(:apps) do |app|
(app["server_roles"] & no...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Application Rails Recipe
30
deploy_revision app['id'] do
revision app[...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Radiant Database Master Role
31
name "radiant_database_master"
descrip...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Database Master Recipe
32
search(:apps) do |app|
(app['database_master...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Radiant Load Balancer Role
33
name "radiant_load_balancer"
description...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Haproxy App Load Balancer Recipe
34
pool_members = search("node", "rol...
Copyright © 2010 Opscode, Inc - All Rights Reserved
Resources/Questions
35
www.opscode.com/chef
IRC and Mailing lists
‣ ir...
Upcoming SlideShare
Loading in...5
×

Data driven app deploys with chef frontdev

1,286
-1

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,286
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Data driven app deploys with chef frontdev

  1. 1. Copyright © 2010 Opscode, Inc - All Rights Reserved Speaker: ‣ joshua@opscode.com ‣ @jtimberman ‣ www.opscode.com Joshua Timberman Sr. Solutions Engineer 1 Data Driven App Deploys Thursday, November 18, 2010
  2. 2. Copyright © 2010 Opscode, Inc - All Rights Reserved 2http://www.flickr.com/photos/anotherphotograph/2100904507/sizes/o/ System administrator Many environments Opscode: Training, Services Thursday, November 18, 2010
  3. 3. Copyright © 2010 Opscode, Inc - All Rights Reserved http://www.flickr.com/photos/timyates/2854357446/sizes/l/ 3 Rails Developers? Java Developers? Python Developers? Thursday, November 18, 2010
  4. 4. Copyright © 2010 Opscode, Inc - All Rights Reserved 4 Application Deployment Thursday, November 18, 2010
  5. 5. Copyright © 2010 Opscode, Inc - All Rights Reserved Application Deployment 5 tar -x -C /app -f app.tar rsync ~/dev/app www:/app cap deploy Thursday, November 18, 2010
  6. 6. Copyright © 2010 Opscode, Inc - All Rights Reserved Server Configuration 6 Thursday, November 18, 2010
  7. 7. Copyright © 2010 Opscode, Inc - All Rights Reserved Server Configuration Web Servers Load Balancers Database Servers 7 Thursday, November 18, 2010
  8. 8. Copyright © 2010 Opscode, Inc - All Rights Reserved Server Configuration 8 % vi /etc/mysql/my.cnf #!/bin/bash Capfile Thursday, November 18, 2010
  9. 9. Copyright © 2010 Opscode, Inc - All Rights Reserved 9http://www.brooklynstreetart.com/theBlog/wp-content/uploads/2008/12/swedish_chef_bork-sleeper-cell.jpg Thursday, November 18, 2010
  10. 10. Copyright © 2010 Opscode, Inc - All Rights Reserved Chef Client runs on your systems 10 Thursday, November 18, 2010
  11. 11. Copyright © 2010 Opscode, Inc - All Rights Reserved Clients talk to a Chef Server 11 Thursday, November 18, 2010
  12. 12. Copyright © 2010 Opscode, Inc - All Rights Reserved http://www.flickr.com/photos/peterrosbjerg/3913766224/ 12 We call each system you configure a Node Thursday, November 18, 2010
  13. 13. Copyright © 2010 Opscode, Inc - All Rights Reserved Nodes have Attributes 13 { "kernel": { "machine": "x86_64", "name": "Darwin", "os": "Darwin", "version": "Darwin Kernel Version 10.4.0: Fri Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386", "release": "10.4.0" }, "platform_version": "10.6.4", "platform": "mac_os_x", "platform_build": "10F569", "domain": "local", "os": "darwin", "current_user": "jtimberman", "ohai_time": 1278602661.60043, "os_version": "10.4.0", "uptime": "18 days 17 hours 49 minutes 18 seconds", "ipaddress": "10.13.37.116", "hostname": "cider", "fqdn": "cider.local", "uptime_seconds": 1619358 } Kernel info! Platform info! Hostname and IP! Thursday, November 18, 2010
  14. 14. Copyright © 2010 Opscode, Inc - All Rights Reserved Nodes have a Run List 14 What Roles or Recipes to apply in Order Thursday, November 18, 2010
  15. 15. Copyright © 2010 Opscode, Inc - All Rights Reserved 15http://www.flickr.com/photos/laenulfean/374398044/ Nodes have Roles Thursday, November 18, 2010
  16. 16. Copyright © 2010 Opscode, Inc - All Rights Reservedhttp://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/ 16 Recipes are lists of Resources Thursday, November 18, 2010
  17. 17. Copyright © 2010 Opscode, Inc - All Rights Reserved Chef manages Resources on Nodes 17 cookbook_file template service package deploy git http_request link ruby_block log bash execute remote_file user Thursday, November 18, 2010
  18. 18. Copyright © 2010 Opscode, Inc - All Rights Reserved Data bags store arbitrary data 18 Thursday, November 18, 2010
  19. 19. Copyright © 2010 Opscode, Inc - All Rights Reserved Nodes, Roles, Data Bags are Searchable 19 % knife search node “role:webserver” search(:users, “group:sysadmins”) Thursday, November 18, 2010
  20. 20. Copyright © 2010 Opscode, Inc - All Rights Reserved Application Deployment 20 Application Repository ‣ Source ‣ CI / Build Chef Repository cider:~/dev/rails-quick-start (ruby-1.9.2-p0) master ✔ % ls -l total 16 -rw-r--r-- 1 jtimberman staff 3521 Nov 5 13:09 README.md -rw-r--r-- 1 jtimberman staff 2171 Nov 5 13:09 Rakefile drwxr-xr-x 3 jtimberman staff 102 Nov 5 13:09 certificates/ drwxr-xr-x 3 jtimberman staff 102 Nov 5 13:09 config/ drwxr-xr-x 26 jtimberman staff 884 Nov 12 08:16 cookbooks/ drwxr-xr-x 4 jtimberman staff 136 Nov 5 13:25 data_bags/ drwxr-xr-x 9 jtimberman staff 306 Nov 12 08:16 roles/ Thursday, November 18, 2010
  21. 21. Copyright © 2010 Opscode, Inc - All Rights Reserved Chef Repository Roles Cookbooks Application Information ‣ Data Bag! 21 Thursday, November 18, 2010
  22. 22. Copyright © 2010 Opscode, Inc - All Rights Reserved Application Information Data Bag JSON 22 Thursday, November 18, 2010
  23. 23. Copyright © 2010 Opscode, Inc - All Rights Reserved Walkthrough 23 Thursday, November 18, 2010
  24. 24. Copyright © 2010 Opscode, Inc - All Rights Reserved 24 { "id": "radiant", "server_roles": [ "radiant" ], "type": { "radiant": [ "rails", "unicorn" ] }, "database_master_role": [ "radiant_database_master" ], "repository": "git://github.com/radiant/radiant.git", "revision": { "production": "0.9.1" }, Thursday, November 18, 2010
  25. 25. Copyright © 2010 Opscode, Inc - All Rights Reserved 25 base.rb production.rb radiant.rb radiant_database_master.rb radiant_load_balancer.rb radiant_run_migrations.rb Server Roles Thursday, November 18, 2010
  26. 26. Copyright © 2010 Opscode, Inc - All Rights Reserved Base Role 26 name "base" description "Base role applied to all nodes." run_list( "recipe[apt]", "recipe[git]", "recipe[build-essential]", "recipe[ruby]" ) Thursday, November 18, 2010
  27. 27. Copyright © 2010 Opscode, Inc - All Rights Reserved Production Role 27 name "production" description "Nodes in the production environment." default_attributes( "app_environment" => "production" ) Thursday, November 18, 2010
  28. 28. Copyright © 2010 Opscode, Inc - All Rights Reserved Radiant Role 28 name "radiant" description "radiant front end application server." run_list( "recipe[mysql::client]", "recipe[application]" ) Thursday, November 18, 2010
  29. 29. Copyright © 2010 Opscode, Inc - All Rights Reserved Application Recipe 29 search(:apps) do |app| (app["server_roles"] & node.run_list.roles).each do |app_role| app["type"][app_role].each do |thing| node.run_state[:current_app] = app include_recipe "application::#{thing}" end end end node.run_state.delete(:current_app) Thursday, November 18, 2010
  30. 30. Copyright © 2010 Opscode, Inc - All Rights Reserved Application Rails Recipe 30 deploy_revision app['id'] do revision app['revision'][node.app_environment] repository app['repository'] user app['owner'] group app['group'] deploy_to app['deploy_to'] environment 'RAILS_ENV' => node.app_environment action app['force'][node.app_environment] ? :force_deploy : :deploy ... Thursday, November 18, 2010
  31. 31. Copyright © 2010 Opscode, Inc - All Rights Reserved Radiant Database Master Role 31 name "radiant_database_master" description "Database master for the radiant application." run_list( "recipe[database::master]" ) Thursday, November 18, 2010
  32. 32. Copyright © 2010 Opscode, Inc - All Rights Reserved Database Master Recipe 32 search(:apps) do |app| (app['database_master_role'] & node.run_list.roles).each do | dbm_role| app['databases'].each do |env,db| if env =~ /#{node[:app_environment]}/ root_pw = node["mysql"]["server_root_password"] mysql_database "create #{db['database']}" do host "localhost" username "root" password root_pw database db['database'] action [:create_db] end end end end end Thursday, November 18, 2010
  33. 33. Copyright © 2010 Opscode, Inc - All Rights Reserved Radiant Load Balancer Role 33 name "radiant_load_balancer" description "radiant load balancer" run_list( "recipe[haproxy::app_lb]" ) override_attributes( "haproxy" => { "app_server_role" => "radiant" } ) Thursday, November 18, 2010
  34. 34. Copyright © 2010 Opscode, Inc - All Rights Reserved Haproxy App Load Balancer Recipe 34 pool_members = search("node", "role:#{node['haproxy'] ['app_server_role']} AND app_environment:#{node['app_environment']}") || [] template "/etc/haproxy/haproxy.cfg" do source "haproxy-app_lb.cfg.erb" owner "root" group "root" mode 0644 variables :pool_members => pool_members notifies :restart, resources(:service => "haproxy") end Thursday, November 18, 2010
  35. 35. Copyright © 2010 Opscode, Inc - All Rights Reserved Resources/Questions 35 www.opscode.com/chef IRC and Mailing lists ‣ irc.freenode.net #chef ‣ lists.opscode.com Twitter: ‣ @opscode, #opschef ‣ @jtimberman Questions? Thursday, November 18, 2010
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×