SlideShare a Scribd company logo
1 of 45
Download to read offline
Customizing Chef
For Fun and Profit
@jonlives
Jon Cowie
Sr Operations Engineer
@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

What's hot

Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Software, Inc.
 
Chef + AWS + CodeIgniter
Chef + AWS + CodeIgniterChef + AWS + CodeIgniter
Chef + AWS + CodeIgniter
ciconf
 

What's hot (20)

Velocity EU 2014 — Offline-first web apps
Velocity EU 2014 — Offline-first web appsVelocity EU 2014 — Offline-first web apps
Velocity EU 2014 — Offline-first web apps
 
Python for AngularJS
Python for AngularJSPython for AngularJS
Python for AngularJS
 
Breaking Technology Silos with Chef
Breaking Technology Silos with ChefBreaking Technology Silos with Chef
Breaking Technology Silos with Chef
 
Chef Tutorial for DEVOPS Newbies
Chef Tutorial for DEVOPS NewbiesChef Tutorial for DEVOPS Newbies
Chef Tutorial for DEVOPS Newbies
 
Chef
ChefChef
Chef
 
Opscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with ChefOpscode Webinar: Managing Your VMware Infrastructure with Chef
Opscode Webinar: Managing Your VMware Infrastructure with Chef
 
Rack
RackRack
Rack
 
Chef - managing yours servers with Code
Chef - managing yours servers with CodeChef - managing yours servers with Code
Chef - managing yours servers with Code
 
Cucumber
CucumberCucumber
Cucumber
 
Chef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation SetupChef Fundamentals Training Series Module 2: Workstation Setup
Chef Fundamentals Training Series Module 2: Workstation Setup
 
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
Chef Fundamentals Training Series Module 4: The Chef Client Run and Expanding...
 
Automating your infrastructure with Chef
Automating your infrastructure with ChefAutomating your infrastructure with Chef
Automating your infrastructure with Chef
 
The unintended benefits of Chef
The unintended benefits of ChefThe unintended benefits of Chef
The unintended benefits of Chef
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef Supermarket
 
Chef Intro @ SF Bay Area LSPE meetup
Chef Intro @ SF Bay Area LSPE meetupChef Intro @ SF Bay Area LSPE meetup
Chef Intro @ SF Bay Area LSPE meetup
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Chef + AWS + CodeIgniter
Chef + AWS + CodeIgniterChef + AWS + CodeIgniter
Chef + AWS + CodeIgniter
 
Server Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.jsServer Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.js
 
ActiveRecordのテーブル名の話
ActiveRecordのテーブル名の話ActiveRecordのテーブル名の話
ActiveRecordのテーブル名の話
 
Building a Private Supermarket for your Organization - ChefConf 2015
Building a Private Supermarket for your Organization - ChefConf 2015 Building a Private Supermarket for your Organization - ChefConf 2015
Building a Private Supermarket for your Organization - ChefConf 2015
 

Viewers also liked (6)

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

Similar to Customizing Chef for Fun and Profit

SELF 2011: Deploying Django Application Stacks with Chef
SELF 2011: Deploying Django Application Stacks with ChefSELF 2011: Deploying Django Application Stacks with Chef
SELF 2011: Deploying Django Application Stacks with Chef
Chef Software, Inc.
 
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil DibowitzAtmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
PROIDEA
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Software, Inc.
 
Chef Analytics (Chef NYC Meeting - July 2014)
Chef Analytics (Chef NYC Meeting - July 2014)Chef Analytics (Chef NYC Meeting - July 2014)
Chef Analytics (Chef NYC Meeting - July 2014)
James Casey
 

Similar to Customizing Chef for Fun and Profit (20)

Cheffing Etsy - Do too many cooks spoil the soup?
Cheffing Etsy - Do too many cooks spoil the soup?Cheffing Etsy - Do too many cooks spoil the soup?
Cheffing Etsy - Do too many cooks spoil the soup?
 
Introduction to Cooking with Chef
Introduction to Cooking with ChefIntroduction to Cooking with Chef
Introduction to Cooking with Chef
 
Chef at Etsy
Chef at EtsyChef at Etsy
Chef at Etsy
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
 
Chef for openstack
Chef for openstackChef for openstack
Chef for openstack
 
SELF 2011: Deploying Django Application Stacks with Chef
SELF 2011: Deploying Django Application Stacks with ChefSELF 2011: Deploying Django Application Stacks with Chef
SELF 2011: Deploying Django Application Stacks with Chef
 
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil DibowitzAtmosphere 2014: Really large scale systems configuration - Phil Dibowitz
Atmosphere 2014: Really large scale systems configuration - Phil Dibowitz
 
Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3Node object and roles - Fundamentals Webinar Series Part 3
Node object and roles - Fundamentals Webinar Series Part 3
 
Chef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of ChefChef Fundamentals Training Series Module 1: Overview of Chef
Chef Fundamentals Training Series Module 1: Overview of Chef
 
Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1Overview of Chef - Fundamentals Webinar Series Part 1
Overview of Chef - Fundamentals Webinar Series Part 1
 
Chef - Infrastructure Automation for the Masses
Chef - Infrastructure Automation for the Masses�Chef - Infrastructure Automation for the Masses�
Chef - Infrastructure Automation for the Masses
 
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Common configuration with Data Bags - Fundamentals Webinar Series Part 4Common configuration with Data Bags - Fundamentals Webinar Series Part 4
Common configuration with Data Bags - Fundamentals Webinar Series Part 4
 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
 
Dev-Friendly Ops
Dev-Friendly OpsDev-Friendly Ops
Dev-Friendly Ops
 
Chef Analytics (Chef NYC Meeting - July 2014)
Chef Analytics (Chef NYC Meeting - July 2014)Chef Analytics (Chef NYC Meeting - July 2014)
Chef Analytics (Chef NYC Meeting - July 2014)
 
Using Nagios with Chef
Using Nagios with ChefUsing Nagios with Chef
Using Nagios with Chef
 
Chef Jumpstart
Chef JumpstartChef Jumpstart
Chef Jumpstart
 
AWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomateAWS OpsWorks for Chef Automate
AWS OpsWorks for Chef Automate
 
Chef: Smart infrastructure automation
Chef: Smart infrastructure automationChef: Smart infrastructure automation
Chef: Smart infrastructure automation
 
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
Chef Fundamentals Training Series Module 6: Roles, Environments, Community Co...
 

Recently uploaded

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Customizing Chef for Fun and Profit