Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Infrastructure as Code: Introduction to Chef

Jesse Dearing
September 04, 2012

Infrastructure as Code: Introduction to Chef

The full stack: the final frontier. As developers we take problems and use code to describe the proposed solution to solve the problem using the resources available to us. Infrastructure as Code is a way of codifying the installation of services and software on a machine starting with a fresh image.

This session explores infrastructure as code using Chef and will allow you to manage your infrastructure as resources in code vs. a slew of shell scripts. In addition, talk about Chef testing techniques.

Jesse Dearing

September 04, 2012
Tweet

More Decks by Jesse Dearing

Other Decks in Programming

Transcript

  1. Front-end (HTML, JavaScript) App (Ruby) Data Models (Ruby) Database (PostgreSQL,

    MySQL) OS (Linux) I work in all these layers Infrastructure as Code and Chef live here
  2. Developers ‣Write buggy code ‣Do not develop on systems that

    look like production ‣Builds features to throw over the wall ‣Think that understanding infrastructure is not their problem Operations ‣Stands in the way of deployments ‣Mostly reactive to issues as alerts are triggered ‣Rolls back code that works on my box™ ‣Think that understanding architecture is not their problem ‣Think that understanding architecture is not their problem ‣Think that understanding infrastructure is not their problem
  3. Developers Operations ‣Think that understanding architecture is not their problem

    ‣Think that understanding infrastructure is not their problem
  4. DevOps is about breaking down silos Code inventory (software not

    deployed to production) has no business value Only shipped code has value Devs and Ops are responsible for shipping Give and take: devs take the pager to assist with software issues and ops codifies processes Dev and Ops need to speak a common language
  5. Infrastructure is composed of ๏CPU ๏Memory ๏Network ๏Disks ๏Remote Storage

    ๏Virtual Machines ๏Policy Configuration ๏Firewalls ๏Services
  6. Infrastructure is composed of ๏CPU ๏Memory ๏Network ๏Disks ๏Remote Storage

    ๏Virtual Machines ๏Policy Configuration ๏Firewalls ๏Services CODE Resources
  7. Shell scripts always need tweaking You can’t run shell scripts

    against a given criteria of servers Shell scripts take a lot of work to make idempotent There is a better way!
  8. Chef Solo Write resources Execute them Installs packages, creates files,

    etc. Recipes, Data Bags, Roles Chef-solo Updates system state
  9. Chef Solo Write resources Execute them Installs packages, creates files,

    etc. Recipes, Data Bags, Roles Chef-solo Updates system state Meh.
  10. Only slight improvement over shell scripts But it’s great for

    testing your Chef scripts before uploading them to the server
  11. Node that polls with chef-client chef-server Also sends back metadata

    about the node using Ohai My laptop Modify recipes, search nodes, change variables
  12. Ohai Gathers metadata from the node to send back to

    Chef server •Installed languages •CPU •Kernel version •Settings •IP Address •Users •Groups (Oh, hi)
  13. user "foobar" file "/etc/service.conf" do mode '0640' owner 'foobar' end

    package "nginx" execute "/usr/bin/somecommand" Recipe Example
  14. Configuration is stored on the Chef server API keys, passwords,

    environment/role/instance specific data