SlideShare a Scribd company logo
1 of 29
Download to read offline
Cookbook Reusability
Noah Kantrowitz
Balanced, Inc
The problem
Community cookbooks only
do 90% of what you need.
New Problem

β€’
Complex contribution process.
β€’
Forking during iteration.
β€’
Proliferation of special cases.
Wrapper Cookbooks

β€’
Overriding attributes.
β€’
chef-rewind, here be dragons.
β€’

Extension by prepend/append.
Requirements

β€’ Responsive effort:
5% change

~5% work

β€’ Documented extension mechanism.
Integration with kitchen, berks, etc.
β€’
DevOps
LWRPs?

β€’
Still only prepend/append.
β€’
No substitution except rewind.
β€’
Better, but not by much.
Enter: Classes
class Chef
class Resource::Something < Resource
...
end
class Provider::Something < Provider
...
end
end
Chef::Resource
def initialize(*args)
super
@resource_name = :something
@action = :enable
@allowed_actions = [
:enable, :disable
]
end
Chef::Resource
def path(arg=nil)
set_or_return(:path, arg, {
kind_of: String
})
end
Chef::Provider
def load_current_resource
end
def whyrun_supported?
true
end
def action_enable
...
end
Why?

β€’
β€’ No really, subclassing!
Allows detailed, responsive
β€’
Subclassing.

customization.
Verbosity

β€’ A lot of boilerplate code.
Missing some LWRP DSL goodies.
β€’
Poise
Poise
class Resource::Something < Resource
include Poise
...
end
class Provider::Something < Provider
include Poise
...
end
LWRP-ese
class Resource::Something < Resource
include Poise
actions(:enable, :disable)
attribute(:path, kind_of: String)
end
Notifying Block
def action_enable
notifying_block do
...
end
end
Include Recipe
def action_enable
include_recipe 'something'
end
Lazy Defaults
class Resource::Something < Resource
include Poise
attribute(:path,
default: lazy { node['path'] }
)
end
Option Collector
class Resource::Something < Resource
include Poise
attribute(:database,
option_collector: True)
end
Option Collector
something 'one' do
database host: 'a', port: 8000
end
Option Collector
something 'one' do
database do
host 'a'
port 8000
end
end
Sub-resources
class Resource::Something < Resource
include Poise(container: true)
end
Sub-resources
class Resource::Foo < Resource
include Poise(parent: Something)
end
Sub-resources
something 'one' do
...
foo 'asdf' do
...
end
end
Sub-resources
something 'one' do
...
end
foo 'asdf' do
parent 'one'
end
Sub-resources
something 'one'
foo 'asdf'
Distribution
β€’ Cookbooks?
β€’ Gems?

More Related Content

Similar to Reusable Cookbook Patterns

Lwrp presentation
Lwrp presentationLwrp presentation
Lwrp presentation
geekbri
Β 
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.
Β 
Emerging chef patterns and practices
Emerging chef patterns and practicesEmerging chef patterns and practices
Emerging chef patterns and practices
Owain Perry
Β 

Similar to Reusable Cookbook Patterns (20)

Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014
Β 
Introduction to Cooking with Chef
Introduction to Cooking with ChefIntroduction to Cooking with Chef
Introduction to Cooking with Chef
Β 
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
Β 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Β 
Lwrp presentation
Lwrp presentationLwrp presentation
Lwrp presentation
Β 
Chef resources
Chef resourcesChef resources
Chef resources
Β 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul Jones
Β 
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Β 
The Five Stages of Chef Grief: My First 6 months with Chef, and Getting Aroun...
The Five Stages of Chef Grief: My First 6 months with Chef, and Getting Aroun...The Five Stages of Chef Grief: My First 6 months with Chef, and Getting Aroun...
The Five Stages of Chef Grief: My First 6 months with Chef, and Getting Aroun...
Β 
Getting Started with Test-Driven Development at Midwest PHP 2021
Getting Started with Test-Driven Development at Midwest PHP 2021Getting Started with Test-Driven Development at Midwest PHP 2021
Getting Started with Test-Driven Development at Midwest PHP 2021
Β 
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
Β 
Scaling to-5000-nodes
Scaling to-5000-nodesScaling to-5000-nodes
Scaling to-5000-nodes
Β 
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Β 
Building a PaaS using Chef
Building a PaaS using ChefBuilding a PaaS using Chef
Building a PaaS using Chef
Β 
What Makes a Good Cookbook?
What Makes a Good Cookbook?What Makes a Good Cookbook?
What Makes a Good Cookbook?
Β 
Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
Β 
Emerging chef patterns and practices
Emerging chef patterns and practicesEmerging chef patterns and practices
Emerging chef patterns and practices
Β 
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
Β 
Chef at WebMD
Chef at WebMDChef at WebMD
Chef at WebMD
Β 
Background Jobs with Resque
Background Jobs with ResqueBackground Jobs with Resque
Background Jobs with Resque
Β 

Recently uploaded

Models in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl ServiceModels in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl Service
Monica Sydney
Β 
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service HaridwarHaridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
ranekokila
Β 
Deira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in DeiraDeira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in Deira
Monica Sydney
Β 
Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...
Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...
Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...
call girls kolkata
Β 
Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...
Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...
Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...
DipikaDelhi
Β 
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
call girls kolkata
Β 
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
DipikaDelhi
Β 
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
call girls kolkata
Β 
Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...
Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...
Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...
call girls kolkata
Β 
Dubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in DubaiDubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in Dubai
Monica Sydney
Β 
Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...
Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...
Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...
call girls kolkata
Β 

Recently uploaded (20)

🌹Bhubaneswar🌹Ravi Tailkes ❀CALL GIRL 9777949614 ❀CALL GIRLS IN bhubaneswar E...
🌹Bhubaneswar🌹Ravi Tailkes  ❀CALL GIRL 9777949614 ❀CALL GIRLS IN bhubaneswar E...🌹Bhubaneswar🌹Ravi Tailkes  ❀CALL GIRL 9777949614 ❀CALL GIRLS IN bhubaneswar E...
🌹Bhubaneswar🌹Ravi Tailkes ❀CALL GIRL 9777949614 ❀CALL GIRLS IN bhubaneswar E...
Β 
Models in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl ServiceModels in Deira 0567006274 Deira Call girl Service
Models in Deira 0567006274 Deira Call girl Service
Β 
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service HaridwarHaridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Haridwar Call Girls, 8699214473 Hot Girls Service Haridwar
Β 
Deira Call girls 0507330913 Call girls in Deira
Deira Call girls 0507330913 Call girls in DeiraDeira Call girls 0507330913 Call girls in Deira
Deira Call girls 0507330913 Call girls in Deira
Β 
Dahod Call Girl πŸ“ž 8617370543 Low Price Genuine Service
Dahod Call Girl πŸ“ž 8617370543 Low Price Genuine ServiceDahod Call Girl πŸ“ž 8617370543 Low Price Genuine Service
Dahod Call Girl πŸ“ž 8617370543 Low Price Genuine Service
Β 
Hire πŸ’• 8617370543 Khalilabad Call Girls Service Call Girls Agency
Hire πŸ’• 8617370543 Khalilabad Call Girls Service Call Girls AgencyHire πŸ’• 8617370543 Khalilabad Call Girls Service Call Girls Agency
Hire πŸ’• 8617370543 Khalilabad Call Girls Service Call Girls Agency
Β 
Deira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in DeiraDeira Call girl agency 0567006274 Call girls in Deira
Deira Call girl agency 0567006274 Call girls in Deira
Β 
πŸ“ž Contact Number 8617370543VIP Fatehgarh Call Girls
πŸ“ž Contact Number 8617370543VIP Fatehgarh Call GirlsπŸ“ž Contact Number 8617370543VIP Fatehgarh Call Girls
πŸ“ž Contact Number 8617370543VIP Fatehgarh Call Girls
Β 
Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...
Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...
Call Girls in Perumbavoor / 9332606886 Genuine Call girls with real Photos an...
Β 
Call Girls Belonia Just Call πŸ“ž 8617370543 Top Class Call Girl Service Available
Call Girls Belonia Just Call πŸ“ž 8617370543 Top Class Call Girl Service AvailableCall Girls Belonia Just Call πŸ“ž 8617370543 Top Class Call Girl Service Available
Call Girls Belonia Just Call πŸ“ž 8617370543 Top Class Call Girl Service Available
Β 
Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...
Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...
Call girls Service Bellary - 9332606886 Rs 3000 Free Pickup & Drop Services 2...
Β 
Kailashahar Call Girl Whatsapp Number πŸ“ž 8617370543 | Girls Number for Friend...
Kailashahar  Call Girl Whatsapp Number πŸ“ž 8617370543 | Girls Number for Friend...Kailashahar  Call Girl Whatsapp Number πŸ“ž 8617370543 | Girls Number for Friend...
Kailashahar Call Girl Whatsapp Number πŸ“ž 8617370543 | Girls Number for Friend...
Β 
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Call Girls Kozhikode - 9332606886 Our call girls are sure to provide you with...
Β 
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Call girls Service Berhampur - 9332606886 Our call girls are sure to provide ...
Β 
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Call Girls in Kollam - 9332606886 Our call girls are sure to provide you with...
Β 
Deira call girls 0507330913 Call girls in Deira
Deira call girls 0507330913  Call girls in DeiraDeira call girls 0507330913  Call girls in Deira
Deira call girls 0507330913 Call girls in Deira
Β 
Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...
Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...
Call Girls Rajnandgaon / 9332606886 Genuine Call girls with real Photos and N...
Β 
Dubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in DubaiDubai Call girls Service 0524076003 Call girls in Dubai
Dubai Call girls Service 0524076003 Call girls in Dubai
Β 
Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...
Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...
Call girls Service Dombivli - 9332606886 Our call girls are sure to provide y...
Β 
Bhubaneswar🌹Call Girls Chandrashekharpur ❀Komal 9777949614 πŸ’Ÿ Full Trusted CAL...
Bhubaneswar🌹Call Girls Chandrashekharpur ❀Komal 9777949614 πŸ’Ÿ Full Trusted CAL...Bhubaneswar🌹Call Girls Chandrashekharpur ❀Komal 9777949614 πŸ’Ÿ Full Trusted CAL...
Bhubaneswar🌹Call Girls Chandrashekharpur ❀Komal 9777949614 πŸ’Ÿ Full Trusted CAL...
Β 

Reusable Cookbook Patterns