Customizing Chef
For Fun and Profit
@jonlives
Jon Cowie
Sr Operations Engineer
Customizing Chef for Fun and Profit
@jonlives
@jonlives
@jonlives
Beginning of 2010 Today
@jonlives
Chef at Etsy
@jonlives
Chef at Etsy
• Open Source Chef Server

• ~1500 Nodes

• CentOS, some Mac OS X
@jonlives
We Love Chef!
@jonlives
We Know Best.
@jonlives
Absorb what is
useful.
Discard what is
useless.
@jonlives
“I am not smart enough to
build an ontology … that
can encompass all the
variations in infrastructure.
Nobody is, the world
moves too fast.”
@jonlives
There is no
magic pill.
@jonlives
You are the
expert.
@jonlives
Customizability
@jonlives
@jonlives
Thin Server
@jonlives
Thick Client
@jonlives
@jonlives
Get Config Data / Initialize
• Load client.rb
• Server URL
• Auth Credentials
• Paths
• Run ohai
• Collect attributes
• Plugins!
@jonlives
Ohai Plugins
• Add attributes to your
node
• Executed at start of
run
• Single Ruby file
• Highest precedence
@jonlives
Ohai Plugins - v6
provides ‘awesome’
!
awesome Mash.new
awesome[:sauce] = "Sricacha"
awesome[:level] = "11"
@jonlives
Ohai Plugins - v7 (Coming soon!)
Ohai.plugin(:Awesome) do
provides "awesome"
collect_data(:darwin) do
awesome Mash.new
awesome[:sauce] = “Sriracha"
awesome[:level] = 11
end
end
@jonlives
Ohai Plugins - client.rb / solo.rb
Ohai::Config[:plugin_path] << /<path>/plugins
@jonlives
Authenticate / Register
• Authenticate to Server
• <clientkey>.pem
• Register if not already
registered
• <validation>.pem
• If both fail, go directly to
jail.
@jonlives
Load / Build Node
• Download node
• Combine attributes
• Expand run_list
• Order matters!
• Create RunStatus
object
• Run start handlers
@jonlives
Handlers
• Respond to specific
situations
• Start, Report, Exception
• Common Code
@jonlives
Handlers - Common Code
require "chef/handler"
!
class HandlerName < Chef::Handler
def report
# Ruby code goes here
end
end
@jonlives
Handlers - client.rb / solo.rb
require “/path_to/mystarthandler.rb"
!
my_start_handler = MyStartHandler.new
!
start_handlers << my_start_handler
@jonlives
Synchronize Cookbooks
• Get cookbook files list
• Only required recipes,
files & templates
• Compares to local
cache
• Download changes
@jonlives
Set up RunContext
• Cookbook Collection
• Definitions List
• Events
• Notifications
• Node
• Resource Collection
• Empty for now…
@jonlives
Events
• Respond to interesting
events
• Pub / Sub model
• EventDispatch::Base
• Formatter
• Custom Subscriber
@jonlives
Events - Custom Subscriber
require “chef/event_dispatch/base"
!
class AwesomeSubscriber < Chef::EventDispatch::Base
def run_started(run_status)
…
end
# Method for each interesting event
end
@jonlives
Events - Register Subscriber
require "chef/handler"
require “/path/awesome_subscriber.rb'
!
class AwesomeSubscriberStartHandler < Chef::Handler
def report
event_dispatcher_subscriber = AwesomeSubscriber.new
@run_status.events.register(event_dispatcher_subscriber)
end
end
@jonlives
Load Cookbook Data
• Populate Resource
Collection
• Libraries
• Attributes
• Resources / Providers
• Definitions
• Recipes
@jonlives
Converge Node
• Actually changes node
• Apply resource
collection
• Again, order matters!
@jonlives
Finalize
• Successful Run
• Save Node
• Report Handlers
• Failed Run
• Exception Handlers
• 💩
@jonlives
Report & Exception Handlers
def report
if @run_status.success?
# Do a happy dance
elsif @run_status.failed?
# Sad panda.
end
end
@jonlives
Handlers - client.rb / solo.rb
require “/var/chef/handlers/mystarthandler.rb"
require "/var/chef/handlers/mynewhandler.rb"
!
my_start_handler = MyStartHandler.new
my_new_handler = MyNewHandler.new
!
start_handlers << my_start_handler
report_handlers << my_new_handler
exception_handlers << my_new_handler
@jonlives
That RunStatus Object Again…
• Accessible to handlers
• Run status & timings
• Exception and Backtrace
• All & updated resources
• RunContext
• Node object
@jonlives
Don’t fear the code!
• https://github.com/opscode/chef
• lib/chef/handler.rb
• lib/chef/run_status.rb
• lib/chef/run_context.rb
• lib/chef/event_dispatch/base.rb
@jonlives
Um…wat?
@jonlives
Criteria for Customization
Simplicity
Modularity
Visibility
Maintainability
Scalability
@jonlives
November 2014
!
http://jonliv.es/book
!
O’Reilly Stand
@jonlives
Thanks!
Questions?
!
Office Hours @ 3.15, Marina Room
@jonlives / http://jonliv.es / jcowie@etsy.com

More Related Content

PDF
Chef at WebMD
PPTX
Cook Infrastructure with chef -- Justeat.IN
KEY
Cooking with Chef
PDF
The Environment Restaurant
PPT
Chef, Devops, and You
PPTX
Chef for Openstack
PDF
There and Back Again: How We Drank the Chef Kool-Aid, Sobered Up, and Learned...
PPTX
Opscode Chef for Dummies
Chef at WebMD
Cook Infrastructure with chef -- Justeat.IN
Cooking with Chef
The Environment Restaurant
Chef, Devops, and You
Chef for Openstack
There and Back Again: How We Drank the Chef Kool-Aid, Sobered Up, and Learned...
Opscode Chef for Dummies

What's hot (20)

PDF
Velocity EU 2014 — Offline-first web apps
PDF
Python for AngularJS
PPTX
Breaking Technology Silos with Chef
PPTX
Chef Tutorial for DEVOPS Newbies
PDF
PPTX
Opscode Webinar: Managing Your VMware Infrastructure with Chef
KEY
Rack
PPT
Chef - managing yours servers with Code
KEY
PDF
Chef Fundamentals Training Series Module 2: Workstation Setup
PDF
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
PDF
Automating your infrastructure with Chef
PDF
The unintended benefits of Chef
PPTX
A Supermarket of Your Own: Running a Private Chef Supermarket
PDF
Chef Intro @ SF Bay Area LSPE meetup
ODP
Introduction to Chef
PPTX
Chef + AWS + CodeIgniter
PDF
Server Check.in case study - Drupal and Node.js
PDF
ActiveRecordのテーブル名の話
PDF
Building a Private Supermarket for your Organization - ChefConf 2015
Velocity EU 2014 — Offline-first web apps
Python for AngularJS
Breaking Technology Silos with Chef
Chef Tutorial for DEVOPS Newbies
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Rack
Chef - managing yours servers with Code
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Automating your infrastructure with Chef
The unintended benefits of Chef
A Supermarket of Your Own: Running a Private Chef Supermarket
Chef Intro @ SF Bay Area LSPE meetup
Introduction to Chef
Chef + AWS + CodeIgniter
Server Check.in case study - Drupal and Node.js
ActiveRecordのテーブル名の話
Building a Private Supermarket for your Organization - ChefConf 2015
Ad

Viewers also liked (6)

PDF
Intro to Git, GitHub, and Devpost
PPTX
OSS - enterprise adoption strategy and governance
PDF
Docker's Killer Feature: The Remote API
PPTX
Applying software engineering to configuration management
PDF
Corporate Open Source Anti-patterns
PDF
(旧版) オープンソースライセンスの基礎と実務
Intro to Git, GitHub, and Devpost
OSS - enterprise adoption strategy and governance
Docker's Killer Feature: The Remote API
Applying software engineering to configuration management
Corporate Open Source Anti-patterns
(旧版) オープンソースライセンスの基礎と実務
Ad

Similar to Customizing Chef for Fun and Profit (20)

PDF
Cheffing Etsy - Do too many cooks spoil the soup?
PDF
Introduction to Cooking with Chef
PDF
Chef at Etsy
PDF
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
PDF
Chef for openstack
KEY
SELF 2011: Deploying Django Application Stacks with Chef
PDF
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
PDF
Node object and roles - Fundamentals Webinar Series Part 3
PDF
Chef Fundamentals Training Series Module 1: Overview of Chef
PDF
Overview of Chef - Fundamentals Webinar Series Part 1
PDF
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
ODP
Configuration management with Chef
PPTX
Dev-Friendly Ops
PDF
Chef Analytics (Chef NYC Meeting - July 2014)
KEY
Using Nagios with Chef
PPTX
Chef Jumpstart
PDF
Chef: Smart infrastructure automation
PDF
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
PPTX
Infrastructure modeling with chef
PDF
Chaione Ember.js Training
Cheffing Etsy - Do too many cooks spoil the soup?
Introduction to Cooking with Chef
Chef at Etsy
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Chef for openstack
SELF 2011: Deploying Django Application Stacks with Chef
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Node object and roles - Fundamentals Webinar Series Part 3
Chef Fundamentals Training Series Module 1: Overview of Chef
Overview of Chef - Fundamentals Webinar Series Part 1
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Configuration management with Chef
Dev-Friendly Ops
Chef Analytics (Chef NYC Meeting - July 2014)
Using Nagios with Chef
Chef Jumpstart
Chef: Smart infrastructure automation
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Infrastructure modeling with chef
Chaione Ember.js Training

Recently uploaded (20)

PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Getting Started with Data Integration: FME Form 101
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
The various Industrial Revolutions .pptx
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
CloudStack 4.21: First Look Webinar slides
PDF
Architecture types and enterprise applications.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Five Habits of High-Impact Board Members
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
Tartificialntelligence_presentation.pptx
PDF
Unlock new opportunities with location data.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
DOCX
search engine optimization ppt fir known well about this
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Zenith AI: Advanced Artificial Intelligence
Hindi spoken digit analysis for native and non-native speakers
Getting Started with Data Integration: FME Form 101
NewMind AI Weekly Chronicles – August ’25 Week III
The various Industrial Revolutions .pptx
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
A review of recent deep learning applications in wood surface defect identifi...
A novel scalable deep ensemble learning framework for big data classification...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
CloudStack 4.21: First Look Webinar slides
Architecture types and enterprise applications.pdf
WOOl fibre morphology and structure.pdf for textiles
Five Habits of High-Impact Board Members
Developing a website for English-speaking practice to English as a foreign la...
Tartificialntelligence_presentation.pptx
Unlock new opportunities with location data.pdf
Getting started with AI Agents and Multi-Agent Systems
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
search engine optimization ppt fir known well about this

Customizing Chef for Fun and Profit