Skip to content

Latest commit

 

History

History
154 lines (120 loc) · 3.22 KB

slides.md

File metadata and controls

154 lines (120 loc) · 3.22 KB

Teaching Chef

!SLIDE

Chef

!SLIDE left

The Framework

Chef vs Chef-Solo

  • Chef-Solo runs on the local machine and requires dependencies to be on that machine
  • Chef has a server and nodes
    • the server contains dependencies and instructions
    • the node communicates with the server to configure itself

I don't know much about Chef-Solo.

!SLIDE left

The Framework

Chef Server

  • stores data needed for the chef run (more on this later)
  • has a web UI
  • indexes data about nodes for searching

Two options:

Hosted Chef

  • pay OpsWorks to provide the Chef server
  • support

Open Source Chef

  • build your own server
  • no support, but also no boundaries

!SLIDE left

The Guts

Basically two components: the Chef Repo and Cookbooks

Chef Repo

  • analogous to a rails app; it's the driver of your infrastructure
    • knife gem for operating on the chef server
    • cucumber-chef gem for BDD

Cookbooks

  • analogous to a gem, but more integral
    • contains the code necessary to accomplish some specific goal (e.g. install monit, or update the apt-cache)

!SLIDE left

Initial setup

  1. Init the chef-repo
  1. Set up the chef server
  1. Connect your chef repository to the server
  1. Make your first cookbook
  1. Use it in your chef-repo

!SLIDE left

Initial setup - continued

  1. Run it on a node
  • Use Knife-EC2 to launch nodes
  • Run the chef-client. Two options:
    • ssh onto the target machine
      • chef-repo $ knife node show NODE_NAME
      • chef-repo $ ssh user@ip
      • chef-node $ chef-client
    • use knife ssh
      • bundle exec knife ssh 'name:NODE_NAME' 'chef-client'
        • useful switches:
          • -i /path/to/chef.pem
          • -x root run as root user (default is ubuntu)

!SLIDE left

Anatomy of a Chef Repo

  • chef-repo/
    • config/
      • rake.rb
    • cookbooks/
    • data_bags/
    • environments/
    • roles/
    • Rakefile
    • chefignore
    • README.md

!SLIDE left

Anatomy of a Chef Repo

My additions:

  • chef-repo/
    • ...
    • features/
      • step_definitions/
      • support/
        • environments/
          • test.rb
        • env.rb
    • lib/
      • tasks/
    • Cheffile
    • Cheffile.lock
    • Gemfile
    • Gemfile.lock

!SLIDE left

Anatomy of a Chef Cookbook

  • my_cookbook/
    • attributes/
      • default.rb
    • definitions/
    • files/
      • default/
    • libraries/
    • providers/
    • recipes/
      • default.rb
    • resources/
    • templates/
    • metadata.rb
    • README.md

!SLIDE left

Anatomy of a Chef Cookbook

My additions:

  • my_cookbook/
    • ...
    • spec/
      • spec_helper.rb
      • default_spec.rb
    • Cheffile
    • Cheffile.lock
    • Gemfile
    • Gemfile.lock