Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Infrastructure Automation
Speakers:
           with Chef
Adam Jacob CTO
Christopher Brown VP Engineering
Joshua Timberman ...
• Adam Jacob
• Christopher Brown
• Joshua Timberman


        http://www.flickr.com/photos/anotherphotograph/2100904507/siz...
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/si...
• Developers?
• Systems Administrators?
• “Business” People?


                            http://www.flickr.com/photos/tim...
• Developers?
• Systems Administrators?
• “Business” People?
• Executives?

                            http://www.flickr.c...
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/pho...
At a High Level...

• A library for configuration management
• A configuration management system



                        ...
At a High Level...

• A library for configuration management
• A configuration management system
• A systems integration pla...
At a High Level...

• A library for configuration management
• A configuration management system
• A systems integration pla...
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/...
Principles

• Idempotent
• Reasonability
• Sane defaults, easily changed
• Hackability

                http://www.flickr.c...
Principles

• Idempotent
• Reasonability
• Sane defaults, easily changed
• Hackability
• TMTOWTDI
                http://w...
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....
The world moves
       pretty fast
• Primitives
• Enable you to solve your
  problems
• Your best skill is knowing
  your ...
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...
So you better be ready

• You need a 3rd generation
  language
• You’re already a
  programmer




                http://...
So you better be ready

• You need a 3rd generation
  language
• You’re already a
  programmer
• You’ve just been lied to
...
Chef enables
 Infrastructure as Code


Manage configuration as idempotent Resources.
        Put them together in Recipes.
...
Infrastructure as Code




        http://www.flickr.com/photos/wonderlane/2306082998/



         Copyright © 2010 Opscode...
Infrastructure as Code is...




                 http://www.flickr.com/photos/kwerfeldein/2634561264/sizes/o/
            ...
Infrastructure as Code is...
A technical
domain revolving
around building
and managing
infrastructure
programmatically


 ...
Enable the reconstruction of
 the business from nothing
     but a source code
  repository, an application
data backup, a...
Theory of Constraints



http://www.flickr.com/photos/mabar/313860092/   Copyright © 2010 Opscode, Inc - All Rights Reserve...
Your Prime Constraint Should Be




                                                                    http://www.flickr.c...
Your Prime Constraint Should Be


   The time it
    takes to
  restore your
   application
      data



                ...
Philosophy
 Sidebar
Wax Philosophical

• We are craftsmen and artists
• You need great brushes and tools
• But nobody remembers Gaudi’s hammer...
• Can only be
                                                               measured
                                    ...
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’)



           ...
Nodes have a Run List
What Roles or Recipes to apply
          in Order


           Copyright © 2010 Opscode, Inc - All R...
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’)



              Copyri...
Roles have a Run List
What Roles or Recipes to apply
          in Order


           Copyright © 2010 Opscode, Inc - All R...
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.
                     ...
A Resource...




Is a declarative description of the state you desire a part
of your node to be in.
                     ...
A Resource...

•   Is of a given type.




          Is a declarative description of the state you desire a part
         ...
A Resource...

•   Is of a given type.

•   Has a name.




          Is a declarative description of the state you desire...
A Resource...

•   Is of a given type.

•   Has a name.

•   Has attributes.




          Is a declarative description of...
A Resource...

•   Is of a given type.

•   Has a name.

•   Has attributes.

•   Takes actions to
    bring the resource ...
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.




                                      ...
A Provider...
Knows how to actually perform the actions specified by a resource.


                                        ...
A Provider...
     Knows how to actually perform the actions specified by a resource.


                                   ...
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/2...
A Recipe...
Applies resources in the order they are specified




           http://www.flickr.com/photos/roadsidepictures/2...
A Recipe...
               Applies resources in the order they are specified


                                            ...
A Recipe...
               Applies resources in the order they are specified




•   Evaluates resources
    in the order t...
A Recipe...
Applies resources in the order they are specified




           http://www.flickr.com/photos/roadsidepictures/2...
A Recipe...
               Applies resources in the order they are specified




•   Can include other
    recipes.




   ...
A Recipe...
                    Applies resources in the order they are specified




•   Can include other
    recipes.

•...
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 ...
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 Res...
Common Cookbook Components

Recipes
Assets (files/templates)
Attributes




            Copyright © 2010 Opscode, Inc - All...
Common Cookbook Components

Recipes
Assets (files/templates)
Attributes
Metadata




            Copyright © 2010 Opscode, ...
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




                    Copyrig...
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 © 2...
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 Reser...
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 ©...
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’)



             ...
Data bags make recipes
  awesome-r (that’s
     totally a word)

        Copyright © 2010 Opscode, Inc - All Rights Reserv...
Data bags make recipes
  awesome-r (that’s
     totally a word)

        Copyright © 2010 Opscode, Inc - All Rights Reserv...
Working with Chef



      Copyright © 2010 Opscode, Inc - All Rights Reserved   58
Create your Chef
          Repostiory
$ git clone http://github.com/opscode/chef-
repo.git




                   Copyrigh...
Configure knife
Everything you can do in Chef, you can do from the
command line with Knife.




           Per-directory co...
Download some
               cookbooks
             $ knife cookbook site vendor rails -d
INFO:   Downloading rails from t...
Check out the Rails
      recipe...
$ vim cookbooks/rails/recipes/default.rb




                 Copyright © 2010 Opscode...
Upload them!
          $ knife cookbook upload -a

             These run as root, kids.

Let’s not blindly trust the upst...
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 Res...
Launch a new Rails
     Server
$ knife rackspace server create 'role[rails]'

$ knife ec2 server create ‘role[rails]’



O...
Chef runs on your new
         server
                 $ sudo chef-client

INFO: Starting Chef Run
...
INFO: Chef Run comp...
Marvel at Rails being
     installed
 $ knife ssh role:rails ‘gem list | grep rails’


                 Knife SSH!
    “Se...
Decide you want Rails 3
        instead
             $ vim cookbooks/rails/default




The vendor pattern means that you c...
Upload your changed
     cookbook
   $ knife cookbook upload rails



    Only uploads the changed file.


            Copy...
Run chef and verify
$ knife ssh role:rails ‘sudo chef-client && gem list |
                       grep rails’

cook-prod-i...
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




               ...
Upcoming SlideShare
Loading in …5
×

Infrastructure Automation with Chef

27,078 views

Published on

Introduction to Chef, from Velocity 2010.

Published in: Technology, Education

Infrastructure Automation with Chef

  1. 1. 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
  2. 2. • Adam Jacob • Christopher Brown • Joshua Timberman http://www.flickr.com/photos/anotherphotograph/2100904507/sizes/o/
  3. 3. http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  4. 4. • Developers? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  5. 5. • Developers? • Systems Administrators? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  6. 6. • Developers? • Systems Administrators? • “Business” People? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  7. 7. • Developers? • Systems Administrators? • “Business” People? • Executives? http://www.flickr.com/photos/timyates/2854357446/sizes/l/
  8. 8. http://www.brooklynstreetart.com/theBlog/wp-content/uploads/2008/12/swedish_chef_bork-sleeper-cell.jpg
  9. 9. At a High Level... http://www.flickr.com/photos/asten/2159525309/sizes/l/
  10. 10. At a High Level... • A library for configuration management http://www.flickr.com/photos/asten/2159525309/sizes/l/
  11. 11. At a High Level... • A library for configuration management • A configuration management system http://www.flickr.com/photos/asten/2159525309/sizes/l/
  12. 12. 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/
  13. 13. 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/
  14. 14. http://www.flickr.com/photos/gi/518613153/sizes/o/
  15. 15. Principles • Idempotent http://www.flickr.com/photos/gi/518613153/sizes/o/
  16. 16. Principles • Idempotent • Reasonability http://www.flickr.com/photos/gi/518613153/sizes/o/
  17. 17. Principles • Idempotent • Reasonability • Sane defaults, easily changed http://www.flickr.com/photos/gi/518613153/sizes/o/
  18. 18. Principles • Idempotent • Reasonability • Sane defaults, easily changed • Hackability http://www.flickr.com/photos/gi/518613153/sizes/o/
  19. 19. Principles • Idempotent • Reasonability • Sane defaults, easily changed • Hackability • TMTOWTDI http://www.flickr.com/photos/gi/518613153/sizes/o/
  20. 20. http://www.flickr.com/photos/gi/518613153/sizes/o/
  21. 21. The world moves pretty fast • Primitives http://www.flickr.com/photos/gi/518613153/sizes/o/
  22. 22. The world moves pretty fast • Primitives • Enable you to solve your problems http://www.flickr.com/photos/gi/518613153/sizes/o/
  23. 23. 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/
  24. 24. http://www.flickr.com/photos/gi/518613153/sizes/o/
  25. 25. So you better be ready • You need a 3rd generation language http://www.flickr.com/photos/gi/518613153/sizes/o/
  26. 26. 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/
  27. 27. 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/
  28. 28. Chef enables Infrastructure as Code Manage configuration as idempotent Resources. Put them together in Recipes. Track it like source code. Configure your servers.
  29. 29. Infrastructure as Code http://www.flickr.com/photos/wonderlane/2306082998/ Copyright © 2010 Opscode, Inc - All Rights Reserved 10
  30. 30. Infrastructure as Code is... http://www.flickr.com/photos/kwerfeldein/2634561264/sizes/o/ Copyright © 2010 Opscode, Inc - All Rights Reserved 11
  31. 31. 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
  32. 32. 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
  33. 33. Theory of Constraints http://www.flickr.com/photos/mabar/313860092/ Copyright © 2010 Opscode, Inc - All Rights Reserved 13
  34. 34. Your Prime Constraint Should Be http://www.flickr.com/photos/visualage/2126833132/sizes/o/ Copyright © 2010 Opscode, Inc - All Rights Reserved 14
  35. 35. 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
  36. 36. Philosophy Sidebar
  37. 37. 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/
  38. 38. • Can only be measured by the final solution http://www.flickr.com/photos/aloshbennett/619307160/sizes/l/
  39. 39. A Tour of Chef Copyright © 2010 Opscode, Inc - All Rights Reserved 18
  40. 40. Chef Client runs on your systems Copyright © 2010 Opscode, Inc - All Rights Reserved 19
  41. 41. They talk to Chef Servers Copyright © 2010 Opscode, Inc - All Rights Reserved 20
  42. 42. They can also stand alone - Chef Solo Copyright © 2010 Opscode, Inc - All Rights Reserved 21
  43. 43. We call each system you configure a Node Copyright © 2010 Opscode, Inc - All Rights Reserved 22
  44. 44. Nodes have Attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 23
  45. 45. Attributes are Searchable $ knife search node ‘platform:mac_os_x’ search(:node, ‘platform:mac_os_x’) Copyright © 2010 Opscode, Inc - All Rights Reserved 24
  46. 46. Nodes have a Run List What Roles or Recipes to apply in Order Copyright © 2010 Opscode, Inc - All Rights Reserved 25
  47. 47. Nodes have a Run List Copyright © 2010 Opscode, Inc - All Rights Reserved 26
  48. 48. Nodes have Roles Copyright © 2010 Opscode, Inc - All Rights Reserved 27
  49. 49. Roles Copyright © 2010 Opscode, Inc - All Rights Reserved 28
  50. 50. Roles Describe what a node should be Copyright © 2010 Opscode, Inc - All Rights Reserved 28
  51. 51. Roles Describe what a node should be Copyright © 2010 Opscode, Inc - All Rights Reserved 28
  52. 52. Copyright © 2010 Opscode, Inc - All Rights Reserved 29
  53. 53. Roles are Searchable $ knife search role ‘max_children:50’ search(:role, ‘max_children:50’) Copyright © 2010 Opscode, Inc - All Rights Reserved 30
  54. 54. Roles have a Run List What Roles or Recipes to apply in Order Copyright © 2010 Opscode, Inc - All Rights Reserved 31
  55. 55. Run Lists on Roles expand Copyright © 2010 Opscode, Inc - All Rights Reserved 32
  56. 56. Chef manages Resources on Nodes Copyright © 2010 Opscode, Inc - All Rights Reserved 33
  57. 57. 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/
  58. 58. 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/
  59. 59. 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/
  60. 60. 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/
  61. 61. 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/
  62. 62. 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/
  63. 63. Copyright © 2010 Opscode, Inc - All Rights Reserved 35
  64. 64. Resources take action through Providers Copyright © 2010 Opscode, Inc - All Rights Reserved 36
  65. 65. A Provider... Knows how to actually perform the actions specified by a resource. http://www.flickr.com/photos/affableslinky/562950216/
  66. 66. 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/
  67. 67. 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/
  68. 68. Copyright © 2010 Opscode, Inc - All Rights Reserved 38
  69. 69. Resources Platform Provider http://www.flickr.com/photos/acurbelo/2628837104/sizes/o/
  70. 70. Recipes are lists of Resources Copyright © 2010 Opscode, Inc - All Rights Reserved 40
  71. 71. A Recipe... Applies resources in the order they are specified http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  72. 72. A Recipe... Applies resources in the order they are specified http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  73. 73. 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/
  74. 74. 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/
  75. 75. A Recipe... Applies resources in the order they are specified http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  76. 76. A Recipe... Applies resources in the order they are specified • Can include other recipes. http://www.flickr.com/photos/roadsidepictures/2478953342/sizes/o/
  77. 77. 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/
  78. 78. Order Matters Copyright © 2010 Opscode, Inc - All Rights Reserved 43
  79. 79. Cookbooks are packages for Recipes Copyright © 2010 Opscode, Inc - All Rights Reserved 44
  80. 80. Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  81. 81. Cookbooks Distributable Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  82. 82. Cookbooks Distributable Infrastructure as Code Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  83. 83. Cookbooks Distributable Infrastructure as Code Version control repository Copyright © 2010 Opscode, Inc - All Rights Reserved 45
  84. 84. Common Cookbook Components Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  85. 85. Common Cookbook Components Recipes Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  86. 86. Common Cookbook Components Recipes Assets (files/templates) Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  87. 87. Common Cookbook Components Recipes Assets (files/templates) Attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  88. 88. Common Cookbook Components Recipes Assets (files/templates) Attributes Metadata Copyright © 2010 Opscode, Inc - All Rights Reserved 46
  89. 89. Cookbook directory Copyright © 2010 Opscode, Inc - All Rights Reserved 47
  90. 90. Cookbook assets Copyright © 2010 Opscode, Inc - All Rights Reserved 48
  91. 91. Cookbook assets Files Copyright © 2010 Opscode, Inc - All Rights Reserved 48
  92. 92. Cookbook assets Files ‣ Static assets ‣ Downloaded via remote_file ‣ File specificity Copyright © 2010 Opscode, Inc - All Rights Reserved 48
  93. 93. Cookbook assets Copyright © 2010 Opscode, Inc - All Rights Reserved 49
  94. 94. Cookbook assets Templates Copyright © 2010 Opscode, Inc - All Rights Reserved 49
  95. 95. Cookbook assets Templates ‣ Dynamic assets ‣ ERB (erubis) ‣ File specificity Copyright © 2010 Opscode, Inc - All Rights Reserved 49
  96. 96. Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 50
  97. 97. Cookbooks Attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 50
  98. 98. Cookbooks Attributes ‣ Node attributes Copyright © 2010 Opscode, Inc - All Rights Reserved 50
  99. 99. Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 51
  100. 100. Cookbooks Metadata Copyright © 2010 Opscode, Inc - All Rights Reserved 51
  101. 101. Cookbooks Metadata cookbooks/god/metadata.rb Copyright © 2010 Opscode, Inc - All Rights Reserved 51
  102. 102. Cookbooks Copyright © 2010 Opscode, Inc - All Rights Reserved 52
  103. 103. Cookbooks Other Components Copyright © 2010 Opscode, Inc - All Rights Reserved 52
  104. 104. Cookbooks Other Components ‣ definitions ‣ libraries ‣ resources ‣ providers Copyright © 2010 Opscode, Inc - All Rights Reserved 52
  105. 105. Cookbooks are shareable! Copyright © 2010 Opscode, Inc - All Rights Reserved 53
  106. 106. Data bags store arbitrary data Copyright © 2010 Opscode, Inc - All Rights Reserved 54
  107. 107. A user $ knife data bag show users adam Copyright © 2010 Opscode, Inc - All Rights Reserved 55
  108. 108. Data Bags are Searchable $ knife search users ‘shell:/usr/bin/zsh’ search(:users, ‘/usr/bin/zsh’) Copyright © 2010 Opscode, Inc - All Rights Reserved 56
  109. 109. Data bags make recipes awesome-r (that’s totally a word) Copyright © 2010 Opscode, Inc - All Rights Reserved 57
  110. 110. Data bags make recipes awesome-r (that’s totally a word) Copyright © 2010 Opscode, Inc - All Rights Reserved 57
  111. 111. Working with Chef Copyright © 2010 Opscode, Inc - All Rights Reserved 58
  112. 112. Create your Chef Repostiory $ git clone http://github.com/opscode/chef- repo.git Copyright © 2010 Opscode, Inc - All Rights Reserved 59
  113. 113. 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
  114. 114. 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
  115. 115. Check out the Rails recipe... $ vim cookbooks/rails/recipes/default.rb Copyright © 2010 Opscode, Inc - All Rights Reserved 62
  116. 116. 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
  117. 117. Build a role $ knife role create rails Copyright © 2010 Opscode, Inc - All Rights Reserved 64
  118. 118. Add your Cloudy credentials to knife $ vi ~/.chef/knife.rb Copyright © 2010 Opscode, Inc - All Rights Reserved 65
  119. 119. 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
  120. 120. 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
  121. 121. 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
  122. 122. 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
  123. 123. Upload your changed cookbook $ knife cookbook upload rails Only uploads the changed file. Copyright © 2010 Opscode, Inc - All Rights Reserved 70
  124. 124. 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
  125. 125. Watch now as Mr. Timberman rocks it live. Copyright © 2010 Opscode, Inc - All Rights Reserved 72
  126. 126. Questions? www.opscode.com ‣ Twitter: @opscode, #opschef ‣ irc.freenode.net #chef ‣ lists.opscode.com Copyright © 2010 Opscode, Inc - All Rights Reserved 73

×