SlideShare a Scribd company logo
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
adamleff
Ā 
PPTX
Cook Infrastructure with chef -- Justeat.IN
Rajesh Hegde
Ā 
KEY
Cooking with Chef
Ken Robertson
Ā 
PDF
The Environment Restaurant
Martin de Keijzer
Ā 
PPT
Chef, Devops, and You
Bryan Berry
Ā 
PPTX
Chef for Openstack
Mohit Sethi
Ā 
PDF
There and Back Again: How We Drank the Chef Kool-Aid, Sobered Up, and Learned...
Chef
Ā 
PPTX
Opscode Chef for Dummies
dilippanwar
Ā 
Chef at WebMD
adamleff
Ā 
Cook Infrastructure with chef -- Justeat.IN
Rajesh Hegde
Ā 
Cooking with Chef
Ken Robertson
Ā 
The Environment Restaurant
Martin de Keijzer
Ā 
Chef, Devops, and You
Bryan Berry
Ā 
Chef for Openstack
Mohit Sethi
Ā 
There and Back Again: How We Drank the Chef Kool-Aid, Sobered Up, and Learned...
Chef
Ā 
Opscode Chef for Dummies
dilippanwar
Ā 

What's hot (20)

PDF
Velocity EU 2014 — Offline-first web apps
andrewsmatt
Ā 
PDF
Python for AngularJS
Jeff Schenck
Ā 
PPTX
Breaking Technology Silos with Chef
Sean Walberg
Ā 
PPTX
Chef Tutorial for DEVOPS Newbies
Mamun Rashid, CCDH
Ā 
PDF
Chef
Adrian Moisey
Ā 
PPTX
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Chef Software, Inc.
Ā 
KEY
Rack
shaokun
Ā 
PPT
Chef - managing yours servers with Code
m_richardson
Ā 
KEY
Cucumber
Michael MacDonald
Ā 
PDF
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Software, Inc.
Ā 
PDF
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Software, Inc.
Ā 
PDF
Automating your infrastructure with Chef
John Ewart
Ā 
PDF
The unintended benefits of Chef
Chef Software, Inc.
Ā 
PPTX
A Supermarket of Your Own: Running a Private Chef Supermarket
Nell Shamrell-Harrington
Ā 
PDF
Chef Intro @ SF Bay Area LSPE meetup
mdxp
Ā 
ODP
Introduction to Chef
Knoldus Inc.
Ā 
PPTX
Chef + AWS + CodeIgniter
ciconf
Ā 
PDF
Server Check.in case study - Drupal and Node.js
Jeff Geerling
Ā 
PDF
ActiveRecordć®ćƒ†ćƒ¼ćƒ–ćƒ«åć®č©±
Akira Ohta
Ā 
PDF
Building a Private Supermarket for your Organization - ChefConf 2015
Chef
Ā 
Velocity EU 2014 — Offline-first web apps
andrewsmatt
Ā 
Python for AngularJS
Jeff Schenck
Ā 
Breaking Technology Silos with Chef
Sean Walberg
Ā 
Chef Tutorial for DEVOPS Newbies
Mamun Rashid, CCDH
Ā 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Chef Software, Inc.
Ā 
Rack
shaokun
Ā 
Chef - managing yours servers with Code
m_richardson
Ā 
Cucumber
Michael MacDonald
Ā 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Software, Inc.
Ā 
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Software, Inc.
Ā 
Automating your infrastructure with Chef
John Ewart
Ā 
The unintended benefits of Chef
Chef Software, Inc.
Ā 
A Supermarket of Your Own: Running a Private Chef Supermarket
Nell Shamrell-Harrington
Ā 
Chef Intro @ SF Bay Area LSPE meetup
mdxp
Ā 
Introduction to Chef
Knoldus Inc.
Ā 
Chef + AWS + CodeIgniter
ciconf
Ā 
Server Check.in case study - Drupal and Node.js
Jeff Geerling
Ā 
ActiveRecordć®ćƒ†ćƒ¼ćƒ–ćƒ«åć®č©±
Akira Ohta
Ā 
Building a Private Supermarket for your Organization - ChefConf 2015
Chef
Ā 
Ad

Viewers also liked (6)

PDF
Intro to Git, GitHub, and Devpost
Andrew Kerr
Ā 
PPTX
OSS - enterprise adoption strategy and governance
Prabir Kr Sarkar
Ā 
PDF
Docker's Killer Feature: The Remote API
bcantrill
Ā 
PPTX
Applying software engineering to configuration management
Bart Vanbrabant
Ā 
PDF
Corporate Open Source Anti-patterns
bcantrill
Ā 
PDF
(ę—§ē‰ˆ) ć‚Ŗćƒ¼ćƒ—ćƒ³ć‚½ćƒ¼ć‚¹ćƒ©ć‚¤ć‚»ćƒ³ć‚¹ć®åŸŗē¤ŽćØå®Ÿå‹™
Yutaka Kachi
Ā 
Intro to Git, GitHub, and Devpost
Andrew Kerr
Ā 
OSS - enterprise adoption strategy and governance
Prabir Kr Sarkar
Ā 
Docker's Killer Feature: The Remote API
bcantrill
Ā 
Applying software engineering to configuration management
Bart Vanbrabant
Ā 
Corporate Open Source Anti-patterns
bcantrill
Ā 
(ę—§ē‰ˆ) ć‚Ŗćƒ¼ćƒ—ćƒ³ć‚½ćƒ¼ć‚¹ćƒ©ć‚¤ć‚»ćƒ³ć‚¹ć®åŸŗē¤ŽćØå®Ÿå‹™
Yutaka Kachi
Ā 
Ad

Similar to Customizing Chef for Fun and Profit (20)

PDF
Chef resources
Denis Looby
Ā 
PDF
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Software, Inc.
Ā 
PDF
Chef, Vagrant and Friends
Ben McRae
Ā 
PPTX
Chef
MohanRaviRohitth
Ā 
PDF
Introduction to Cooking with Chef
John Osborne
Ā 
PPTX
Kickstarter - Chef Opswork
Hamza Waqas
Ā 
ODP
Configuration management with Chef
Juan Vicente Herrera Ruiz de Alejo
Ā 
PPTX
London Community Summit 2016 - Fresh New Chef Stuff
Chef
Ā 
PDF
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
Ā 
PDF
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Chef
Ā 
PDF
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Chef
Ā 
PPTX
Chef Jumpstart
Kimball Johnson
Ā 
PDF
Node object and roles - Fundamentals Webinar Series Part 3
Chef
Ā 
PDF
Introduction to chef framework
morgoth
Ā 
PDF
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Software, Inc.
Ā 
PDF
Dive into Chef
Eduardo Scarpellini
Ā 
PDF
Chef@recordedfuture
ulfmansson
Ā 
PDF
Learning chef
Jonathan Carrillo
Ā 
PDF
Chef - Administration for programmers
mrsabo
Ā 
PPTX
DevOps and Chef
PiXeL16
Ā 
Chef resources
Denis Looby
Ā 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Software, Inc.
Ā 
Chef, Vagrant and Friends
Ben McRae
Ā 
Introduction to Cooking with Chef
John Osborne
Ā 
Kickstarter - Chef Opswork
Hamza Waqas
Ā 
Configuration management with Chef
Juan Vicente Herrera Ruiz de Alejo
Ā 
London Community Summit 2016 - Fresh New Chef Stuff
Chef
Ā 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Josh Padnick
Ā 
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Chef
Ā 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Chef
Ā 
Chef Jumpstart
Kimball Johnson
Ā 
Node object and roles - Fundamentals Webinar Series Part 3
Chef
Ā 
Introduction to chef framework
morgoth
Ā 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Software, Inc.
Ā 
Dive into Chef
Eduardo Scarpellini
Ā 
Chef@recordedfuture
ulfmansson
Ā 
Learning chef
Jonathan Carrillo
Ā 
Chef - Administration for programmers
mrsabo
Ā 
DevOps and Chef
PiXeL16
Ā 

More from Jon Cowie (6)

PDF
Building a Healthy Work Life Balance
Jon Cowie
Ā 
PDF
Cheffing Etsy - Do too many cooks spoil the soup?
Jon Cowie
Ā 
PDF
Chef at Etsy
Jon Cowie
Ā 
PDF
Custom Live Media Spinning
Jon Cowie
Ā 
PDF
Bring the Noise
Jon Cowie
Ā 
KEY
Michelin Starred Cooking with Chef
Jon Cowie
Ā 
Building a Healthy Work Life Balance
Jon Cowie
Ā 
Cheffing Etsy - Do too many cooks spoil the soup?
Jon Cowie
Ā 
Chef at Etsy
Jon Cowie
Ā 
Custom Live Media Spinning
Jon Cowie
Ā 
Bring the Noise
Jon Cowie
Ā 
Michelin Starred Cooking with Chef
Jon Cowie
Ā 

Recently uploaded (20)

PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
Ā 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
Ā 
PDF
Software Development Methodologies in 2025
KodekX
Ā 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
Ā 
PDF
OFFOFFBOXā„¢ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
Ā 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
Ā 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
Ā 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
Ā 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
Ā 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
Ā 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
Ā 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
Ā 
PDF
Doc9.....................................
SofiaCollazos
Ā 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
Ā 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
Ā 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
Ā 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
Ā 
OFFOFFBOXā„¢ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
Ā 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
Ā 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
Ā 
The Future of AI & Machine Learning.pptx
pritsen4700
Ā 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
Ā 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
Ā 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
Ā 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
Ā 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
Ā 
Doc9.....................................
SofiaCollazos
Ā 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
Ā 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
Ā 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
Ā 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 

Customizing Chef for Fun and Profit