Infrastructure Automation with Chef
Upcoming SlideShare
Loading in...5
×
 

Infrastructure Automation with Chef

on

  • 15,222 views

Introduction to Chef, from Velocity 2010.

Introduction to Chef, from Velocity 2010.

Statistics

Views

Total Views
15,222
Views on SlideShare
13,221
Embed Views
2,001

Actions

Likes
49
Downloads
748
Comments
2

15 Embeds 2,001

http://www.velankani.net 1116
http://www.scoop.it 437
http://www.royans.net 223
http://velocityconf.com 134
https://twitter.com 40
http://www.twylah.com 13
http://www.linkedin.com 11
http://alok.softvision.in 11
https://summary.radian6.com 5
https://www.linkedin.com 4
http://webcache.googleusercontent.com 2
http://translate.googleusercontent.com 2
http://static.slidesharecdn.com 1
http://www.slideshare.net 1
http://www.techgig.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Great one, Thanks
    Are you sure you want to
    Your message goes here
    Processing…
  • This preso provides some much needed high level description of the chef framework
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Roles are another abstraction that describe a set of configuration functionality about nodes. <br />
  • webserver, dbserver, batch processing server <br /> Attributes applied to node, but stay with the role, add/remove. <br /> Searchable <br />
  • webserver, dbserver, batch processing server <br /> Attributes applied to node, but stay with the role, add/remove. <br /> Searchable <br />
  • Role ruby DSL file. <br />
  • <br />
  • <br />
  • <br />
  • Resources are an abstraction we feed data into. When you write recipes in Chef, you create resources of things you want to configure. <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • type: template <br /> name: grants.sql <br /> parameters: source,owner,group,mode <br /> action: create <br />
  • The abstraction over the commands to run for this platform. <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Platform determines provider, but has sane defaults otherwise <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Cookbooks encapsulate all the components needed to configure the infrastructure. <br />
  • Distribute cookbooks as tarballs either to/from server, with solo, or share with others <br /> They contain the code and assets that configure infrastructure <br /> Keep them in a version control repository <br />
  • Distribute cookbooks as tarballs either to/from server, with solo, or share with others <br /> They contain the code and assets that configure infrastructure <br /> Keep them in a version control repository <br />
  • Distribute cookbooks as tarballs either to/from server, with solo, or share with others <br /> They contain the code and assets that configure infrastructure <br /> Keep them in a version control repository <br />
  • Cookbooks are a directory of code components <br />
  • Cookbooks are a directory of code components <br />
  • Cookbooks are a directory of code components <br />
  • Cookbooks are a directory of code components <br />
  • Cookbook directory with common components. <br /> - metadata can be written in ruby DSL, converted to JSON. <br />
  • non-dynamic, like tarballs or graphics <br /> remote_file resource <br /> file specificity based on node&#x2019;s FQDN, platform, or default <br />
  • non-dynamic, like tarballs or graphics <br /> remote_file resource <br /> file specificity based on node&#x2019;s FQDN, platform, or default <br />
  • <br />
  • <br />
  • Attributes in cookbooks apply to the node object directly. <br /> Two ways to set in cookbooks, &#x2018;set&#x2019; - the cookbook is authoritative, &#x2018;set_unless&#x2019; - node is authoritative <br />
  • Attributes in cookbooks apply to the node object directly. <br /> Two ways to set in cookbooks, &#x2018;set&#x2019; - the cookbook is authoritative, &#x2018;set_unless&#x2019; - node is authoritative <br />
  • Metadata provides hints about the cookbook like packaging system&#x2019;s. Primarily, used to distribute dependencies. Metadata as Ruby code, converted to JSON to upload. <br />
  • Metadata provides hints about the cookbook like packaging system&#x2019;s. Primarily, used to distribute dependencies. Metadata as Ruby code, converted to JSON to upload. <br />
  • Metadata provides hints about the cookbook like packaging system&#x2019;s. Primarily, used to distribute dependencies. Metadata as Ruby code, converted to JSON to upload. <br />
  • Other components of cookbooks that are very useful but not commonly used <br />
  • Other components of cookbooks that are very useful but not commonly used <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Infrastructure Automation with Chef Infrastructure Automation with Chef Presentation Transcript

  • Infrastructure Automation Speakers: with Chef Adam Jacob CTO Christopher Brown VP Engineering Joshua Timberman Sr. Solution Engineer Copyright © 2010 Opscode, Inc - All Rights Reserved 1
  • • Adam Jacob • Christopher Brown • Joshua Timberman http://www.flickr.com/photos/anotherphotograph/2100904507/sizes/o/
  • http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  • • Developers? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  • • Developers? • Systems Administrators? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  • • Developers? • Systems Administrators? • “Business” People? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  • • Developers? • Systems Administrators? • “Business” People? • Executives? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  • http://www.brooklynstreetart.com/theBlog/wp-content/uploads/2008/12/swedish_chef_bork-sleeper-cell.jpg
  • At a High Level... http://www.flickr.com/photos/asten/2159525309/sizes/l/
  • At a High Level... • A library for configuration management http://www.flickr.com/photos/asten/2159525309/sizes/l/
  • At a High Level... • A library for configuration management • A configuration management system http://www.flickr.com/photos/asten/2159525309/sizes/l/
  • At a High Level... • A library for configuration management • A configuration management system • A systems integration platform http://www.flickr.com/photos/asten/2159525309/sizes/l/
  • At a High Level... • A library for configuration management • A configuration management system • A systems integration platform • An API for your entire Infrastructure http://www.flickr.com/photos/asten/2159525309/sizes/l/
  • http://www.flickr.com/photos/gi/518613153/sizes/o/
  • Principles • Idempotent http://www.flickr.com/photos/gi/518613153/sizes/o/
  • Principles • Idempotent • Reasonability http://www.flickr.com/photos/gi/518613153/sizes/o/
  • Principles • Idempotent • Reasonability • Sane defaults, easily changed http://www.flickr.com/photos/gi/518613153/sizes/o/
  • Principles • Idempotent • Reasonability • Sane defaults, easily changed • Hackability http://www.flickr.com/photos/gi/518613153/sizes/o/
  • Principles • Idempotent • Reasonability • Sane defaults, easily changed • Hackability • TMTOWTDI http://www.flickr.com/photos/gi/518613153/sizes/o/
  • http://www.flickr.com/photos/gi/518613153/sizes/o/
  • The world moves pretty fast • Primitives http://www.flickr.com/photos/gi/518613153/sizes/o/
  • The world moves pretty fast • Primitives • Enable you to solve your problems http://www.flickr.com/photos/gi/518613153/sizes/o/
  • The world moves pretty fast • Primitives • Enable you to solve your problems • Your best skill is knowing your systems http://www.flickr.com/photos/gi/518613153/sizes/o/
  • http://www.flickr.com/photos/gi/518613153/sizes/o/
  • So you better be ready • You need a 3rd generation language http://www.flickr.com/photos/gi/518613153/sizes/o/
  • So you better be ready • You need a 3rd generation language • You’re already a programmer http://www.flickr.com/photos/gi/518613153/sizes/o/
  • So you better be ready • You need a 3rd generation language • You’re already a programmer • You’ve just been lied to http://www.flickr.com/photos/gi/518613153/sizes/o/
  • Chef enables Infrastructure as Code Manage configuration as idempotent Resources. Put them together in Recipes. Track it like source code. Configure your servers.
  • Infrastructure as Code http://www.flickr.com/photos/wonderlane/2306082998/ Copyright © 2010 Opscode, Inc - All Rights Reserved 10
  • Infrastructure as Code is... http://www.flickr.com/photos/kwerfeldein/2634561264/sizes/o/ Copyright © 2010 Opscode, Inc - All Rights Reserved 11
  • Infrastructure as Code is... A technical domain revolving around building and managing infrastructure programmatically http://www.flickr.com/photos/kwerfeldein/2634561264/sizes/o/ Copyright © 2010 Opscode, Inc - All Rights Reserved 11
  • Enable the reconstruction of the business from nothing but a source code repository, an application data backup, and bare metal resources. Copyright © 2010 Opscode, Inc - All Rights Reserved 12
  • Theory of Constraints http://www.flickr.com/photos/mabar/313860092/ Copyright © 2010 Opscode, Inc - All Rights Reserved 13
  • Your Prime Constraint Should Be http://www.flickr.com/photos/visualage/2126833132/sizes/o/ Copyright © 2010 Opscode, Inc - All Rights Reserved 14
  • Your Prime Constraint Should Be The time it takes to restore your application data http://www.flickr.com/photos/visualage/2126833132/sizes/o/ Copyright © 2010 Opscode, Inc - All Rights Reserved 14
  • Philosophy Sidebar
  • Wax Philosophical • We are craftsmen and artists • You need great brushes and tools • But nobody remembers Gaudi’s hammer http://www.flickr.com/photos/vgm8383/2686128924/sizes/l/
  • • Can only be measured by the final solution http://www.flickr.com/photos/aloshbennett/619307160/sizes/l/
  • A Tour of Chef Copyright © 2010 Opscode, Inc - All Rights Reserved 18
  • Chef Client runs on your systems Copyright © 2010 Opscode, Inc - All Rights Reserved 19
  • They talk to Chef Servers Copyright © 2010 Opscode, Inc - All Rights Reserved 20
  • They can also stand alone - Chef Solo Copyright © 2010 Opscode, Inc - All Rights Reserved 21
  • We call each system you configure a Node Copyright © 2010 Opscode, Inc - All Rights Reserved 22
  • Nodes have Attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 23
  • Attributes are Searchable $ knife search node ‘platform:mac_os_x’ search(:node, ‘platform:mac_os_x’) Copyright © 2010 Opscode, Inc - All Rights Reserved 24
  • Nodes have a Run List What Roles or Recipes to apply in Order Copyright © 2010 Opscode, Inc - All Rights Reserved 25
  • Nodes have a Run List Copyright © 2010 Opscode, Inc - All Rights Reserved 26
  • Nodes have Roles Copyright © 2010 Opscode, Inc - All Rights Reserved 27
  • Roles Copyright © 2010 Opscode, Inc - All Rights Reserved 28
  • Roles Describe what a node should be Copyright © 2010 Opscode, Inc - All Rights Reserved 28
  • Roles Describe what a node should be Copyright © 2010 Opscode, Inc - All Rights Reserved 28
  • Copyright © 2010 Opscode, Inc - All Rights Reserved 29
  • Roles are Searchable $ knife search role ‘max_children:50’ search(:role, ‘max_children:50’) Copyright © 2010 Opscode, Inc - All Rights Reserved 30
  • Roles have a Run List What Roles or Recipes to apply in Order Copyright © 2010 Opscode, Inc - All Rights Reserved 31
  • Run Lists on Roles expand Copyright © 2010 Opscode, Inc - All Rights Reserved 32
  • Chef manages Resources on Nodes Copyright © 2010 Opscode, Inc - All Rights Reserved 33
  • A Resource... Is a declarative description of the state you desire a part of your node to be in. http://www.flickr.com/photos/xiaming/382205902/sizes/l/
  • A Resource... Is a declarative description of the state you desire a part of your node to be in. http://www.flickr.com/photos/xiaming/382205902/sizes/l/
  • A Resource... • Is of a given type. Is a declarative description of the state you desire a part of your node to be in. http://www.flickr.com/photos/xiaming/382205902/sizes/l/
  • A Resource... • Is of a given type. • Has a name. Is a declarative description of the state you desire a part of your node to be in. http://www.flickr.com/photos/xiaming/382205902/sizes/l/
  • A Resource... • Is of a given type. • Has a name. • Has attributes. Is a declarative description of the state you desire a part of your node to be in. http://www.flickr.com/photos/xiaming/382205902/sizes/l/
  • A Resource... • Is of a given type. • Has a name. • Has attributes. • Takes actions to bring the resource to a declared state. Is a declarative description of the state you desire a part of your node to be in. http://www.flickr.com/photos/xiaming/382205902/sizes/l/
  • Copyright © 2010 Opscode, Inc - All Rights Reserved 35
  • Resources take action through Providers Copyright © 2010 Opscode, Inc - All Rights Reserved 36
  • A Provider... Knows how to actually perform the actions specified by a resource. http://www.flickr.com/photos/affableslinky/562950216/
  • A Provider... Knows how to actually perform the actions specified by a resource. Apt,Yum, Rubygems, Multiple providers per resource type. Portage, Macports, FreeBSD Ports, etc. http://www.flickr.com/photos/affableslinky/562950216/
  • A Provider... Knows how to actually perform the actions specified by a resource. Apt,Yum, Rubygems, Multiple providers per resource type. Portage, Macports, FreeBSD Ports, etc. Can be overridden with the provider attribute on a resource. http://www.flickr.com/photos/affableslinky/562950216/
  • Copyright © 2010 Opscode, Inc - All Rights Reserved 38
  • Resources Platform Provider http://www.flickr.com/photos/acurbelo/2628837104/sizes/o/
  • Recipes are lists of Resources Copyright © 2010 Opscode, Inc - All Rights Reserved 40
  • A Recipe... Applies resources in the order they are specified http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • A Recipe... Applies resources in the order they are specified http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • A Recipe... Applies resources in the order they are specified 1 • Evaluates resources in the order they appear. 2 http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • A Recipe... Applies resources in the order they are specified • Evaluates resources in the order they appear. 1 2 • Adds each resource object to the Resource Collection http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • A Recipe... Applies resources in the order they are specified http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • A Recipe... Applies resources in the order they are specified • Can include other recipes. http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • A Recipe... Applies resources in the order they are specified • Can include other recipes. • Is just Ruby. http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  • Order Matters Copyright © 2010 Opscode, Inc - All Rights Reserved 43
  • Cookbooks are packages for Recipes Copyright © 2010 Opscode, Inc - All Rights Reserved 44
  • Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  • Cookbooks Distributable Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  • Cookbooks Distributable Infrastructure as Code Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  • Cookbooks Distributable Infrastructure as Code Version control repository Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  • Common Cookbook Components Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  • Common Cookbook Components Recipes Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  • Common Cookbook Components Recipes Assets (files/templates) Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  • Common Cookbook Components Recipes Assets (files/templates) Attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  • Common Cookbook Components Recipes Assets (files/templates) Attributes Metadata Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  • Cookbook directory Copyright © 2010 Opscode, Inc - All Rights Reserved 47
  • Cookbook assets Copyright © 2010 Opscode, Inc - All Rights Reserved 48
  • Cookbook assets Files Copyright © 2010 Opscode, Inc - All Rights Reserved 48
  • Cookbook assets Files ‣ Static assets ‣ Downloaded via remote_file ‣ File specificity Copyright © 2010 Opscode, Inc - All Rights Reserved 48
  • Cookbook assets Copyright © 2010 Opscode, Inc - All Rights Reserved 49
  • Cookbook assets Templates Copyright © 2010 Opscode, Inc - All Rights Reserved 49
  • Cookbook assets Templates ‣ Dynamic assets ‣ ERB (erubis) ‣ File specificity Copyright © 2010 Opscode, Inc - All Rights Reserved 49
  • Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 50
  • Cookbooks Attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 50
  • Cookbooks Attributes ‣ Node attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 50
  • Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 51
  • Cookbooks Metadata Copyright © 2010 Opscode, Inc - All Rights Reserved 51
  • Cookbooks Metadata cookbooks/god/metadata.rb Copyright © 2010 Opscode, Inc - All Rights Reserved 51
  • Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 52
  • Cookbooks Other Components Copyright © 2010 Opscode, Inc - All Rights Reserved 52
  • Cookbooks Other Components ‣ definitions ‣ libraries ‣ resources ‣ providers Copyright © 2010 Opscode, Inc - All Rights Reserved 52
  • Cookbooks are shareable! Copyright © 2010 Opscode, Inc - All Rights Reserved 53
  • Data bags store arbitrary data Copyright © 2010 Opscode, Inc - All Rights Reserved 54
  • A user $ knife data bag show users adam Copyright © 2010 Opscode, Inc - All Rights Reserved 55
  • Data Bags are Searchable $ knife search users ‘shell:/usr/bin/zsh’ search(:users, ‘/usr/bin/zsh’) Copyright © 2010 Opscode, Inc - All Rights Reserved 56
  • Data bags make recipes awesome-r (that’s totally a word) Copyright © 2010 Opscode, Inc - All Rights Reserved 57
  • Data bags make recipes awesome-r (that’s totally a word) Copyright © 2010 Opscode, Inc - All Rights Reserved 57
  • Working with Chef Copyright © 2010 Opscode, Inc - All Rights Reserved 58
  • Create your Chef Repostiory $ git clone http://github.com/opscode/chef- repo.git Copyright © 2010 Opscode, Inc - All Rights Reserved 59
  • Configure knife Everything you can do in Chef, you can do from the command line with Knife. Per-directory configurations! Copyright © 2010 Opscode, Inc - All Rights Reserved 60
  • Download some cookbooks $ knife cookbook site vendor rails -d INFO: Downloading rails from the cookbooks site at version 0.8.0 ... INFO: Cookbook rails version 0.8.0 successfully vendored! INFO: Downloading apache2 from the cookbooks site at version 0.12.0 ... INFO: Cookbook apache2 version 0.12.0 successfully vendored! INFO: Downloading ruby from the cookbooks site at version 0.7.0 ... INFO: Cookbook ruby version 0.7.0 successfully vendored! Uses the “vendor branch” pattern, so you can make changes and track the upstream Copyright © 2010 Opscode, Inc - All Rights Reserved 61
  • Check out the Rails recipe... $ vim cookbooks/rails/recipes/default.rb Copyright © 2010 Opscode, Inc - All Rights Reserved 62
  • Upload them! $ knife cookbook upload -a These run as root, kids. Let’s not blindly trust the upstream too much, ok? Copyright © 2010 Opscode, Inc - All Rights Reserved 63
  • Build a role $ knife role create rails Copyright © 2010 Opscode, Inc - All Rights Reserved 64
  • Add your Cloudy credentials to knife $ vi ~/.chef/knife.rb Copyright © 2010 Opscode, Inc - All Rights Reserved 65
  • Launch a new Rails Server $ knife rackspace server create 'role[rails]' $ knife ec2 server create ‘role[rails]’ Or just install Chef on your existing servers Copyright © 2010 Opscode, Inc - All Rights Reserved 66
  • Chef runs on your new server $ sudo chef-client INFO: Starting Chef Run ... INFO: Chef Run complete in 11.852033 seconds Automatically. Copyright © 2010 Opscode, Inc - All Rights Reserved 67
  • Marvel at Rails being installed $ knife ssh role:rails ‘gem list | grep rails’ Knife SSH! “Search for all nodes with role rails” Run the following command Executes in parallel Supports screen, tmux, and macterm Copyright © 2010 Opscode, Inc - All Rights Reserved 68
  • Decide you want Rails 3 instead $ vim cookbooks/rails/default The vendor pattern means that you can just change it, and safely merge any upstream changes later on. Copyright © 2010 Opscode, Inc - All Rights Reserved 69
  • Upload your changed cookbook $ knife cookbook upload rails Only uploads the changed file. Copyright © 2010 Opscode, Inc - All Rights Reserved 70
  • Run chef and verify $ knife ssh role:rails ‘sudo chef-client && gem list | grep rails’ cook-prod-i78f2e213.opscode.us rails (3.0.0- beta4) Run chef on all the Rails systems Then verify the changes. Copyright © 2010 Opscode, Inc - All Rights Reserved 71
  • Watch now as Mr. Timberman rocks it live. Copyright © 2010 Opscode, Inc - All Rights Reserved 72
  • Questions? www.opscode.com ‣ Twitter: @opscode, #opschef ‣ irc.freenode.net #chef ‣ lists.opscode.com Copyright © 2010 Opscode, Inc - All Rights Reserved 73