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

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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 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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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?
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 

Customizing Chef for Fun and Profit