Download - Building Better Chef Community Cookbooks
Tim Smith - @tas50 Community Engineer, Chef
Building Better Community Cookbooks
https://www.pexels.com/photo/mountains-under-cloudy-sky-during-daytime-168865/
https://pixabay.com/en/clock-wall-clock-brick-wall-old-1250204/
Let’s Start With a Little Story
Hypothetical Sysadmin
New to Chef
New to Ruby
New to this DevOps thing
Lets call him 2011 Tim
New to Chef
New to Ruby
New to this DevOps thing
Hypothetical Sysadmin
Tim’s first community cookbook experience
https://www.flickr.com/photos/statefarm/10994875346
My Boss Circa 2011
We need a monitoring system. Go build one and
have it done… this week!
Couldn’t be that hard….
Chef Will Solve Everything
Maybe not…
Oh Wait No RHEL Support
Time to get hacking
https://www.flickr.com/photos/132889348@N07/20607150556
Time to get hacking
https://www.flickr.com/photos/132889348@N07/20607150556
This is basically what ruby looked like to me
Way Too Much Time Later
https://en.wikipedia.org/wiki/Father_Time#/media/File:Romanelli_Chronos_and_his_child.jpg
https://en.wikipedia.org/wiki/Father_Time#/media/File:Romanelli_Chronos_and_his_child.jpg
By week you meant month right?
Way Too Much Time Later
https://www.flickr.com/photos/number7cloud/28013072643
Where are all my nodes?
Hardcoded EVERYTHING!
https://pixabay.com/get/e037b10d2ef71c22d9584518a33219c8b66ae3d111b4154096f5c37a/tool-920263_1920.jpg
Hardcoded Chef searchesHardcoded Chef environments to ignore
Hardcoded Nagios service checksHardcoded Nagios service groups
Just about everything else…hardcoded
A lot of commits later
In the end we had a great cookbookbut the project was a failure
So what did I learn from all this?
http://www.publicdomainpictures.net/view-image.php?image=182073&picture=antique-wood-school-desk
https://commons.wikimedia.org/wiki/File:2010_0515_rama_4_and_sathorn_22a.JPG
Community cookbooks are a tire fire right?
https://www.flickr.com/photos/bitterjug/7670055210
NoIt’s more complicated than that
3000+ Cookbooks7000+ Users
https://en.wikipedia.org/wiki/Supermarket#/media/File:Fredmeyer_edit_1.jpg
Some are Great. Some not so much.They All Solved Someone’s Problem Though
https://commons.wikimedia.org/wiki/File:Rotten,_moldy_and_decaying_oranges.jpg
Some cookbooks are community cookbooks; others are just shared code
https://www.flickr.com/photos/huangjiahui/2893120846
How do we write community cookbooks and not shared code?
https://www.flickr.com/photos/wlodi/3152672560
Community cookbooks are not enterprise cookbooks
https://upload.wikimedia.org/wikipedia/commons/b/b5/VulcanAlbertaEnterpriseReplica.jpg
CommunityCookbook
EnterpriseCookbook
Usage Pattern, Platform Support, Tuneables, etc
Community cookbooks provide well tested and simple interfaces to
composable resources that empower users to write their own
cookbooks which aid in the automation of highly customized
and complex software environments
S
W
A T
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
Simple Interfaces
Wrappable
All platforms supportedTested thoroughly
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
Simple Interfaces
W
A T
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
Technology is hard. Your cookbook shouldn’t be harder
Interface Patterns to Avoid
Large numbers of attributes
Clever abstraction models only you understand
Trying to parameterize the impossible
Understanding Simple Interfaces
Components of a Simple Cookbook
App Binary
Config
Service Management
App Binary
Config
Service Management
Components of a Complex Cookbook
Cookbook components map to Custom Resources nicely
App Binary
Config
Service Management
foo_install
foo_config
foo_service
Component to Custom Resource Mapping
Don’t jump into code. Write test recipe firstThat’s your design
Think about how YOU would want to consume the resources
It’s the hard right thing
Example Test Recipe
S
Wrappable
A T
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
Turn key cookbooks never work2011 Opscode lied to you
Design Patterns to Avoid
Highly opinionated end to end cookbooks
Monolithic recipes (or recipes altogether)
Opinionated dependency installs (ruby, java, etc)
Sample Wrapper Usage PatternsGood and Better Designs
Basic Wrapper
Better Wrapper
S
W
All platforms supportedT
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
All Platforms Supported
Someone somewhere is going to want Gentoo support
Richard Stallman…loves that laptop apparently
S
W
A Tested thoroughly
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
Do you test your changes?On every platform?
Every single commit?
https://upload.wikimedia.org/wikipedia/commons/4/47/StateLibQld_1_100348.jpg
https://upload.wikimedia.org/wikipedia/commons/4/47/StateLibQld_1_100348.jpg
You need automated testing
What to test though?
https://upload.wikimedia.org/wikipedia/commons/4/47/StateLibQld_1_100348.jpg
Cookstyle/Foodcritic
ChefSpec
Test Kitchen / InSpec
https://simple.wikipedia.org/wiki/Insurance_Institute_for_Highway_Safety#/media/File:IIHS_Hyundai_Tucson_crash_test.jpg
Tim’s Hierarchy of Testing Usefulness
https://en.wikipedia.org/wiki/Runway_(fashion)#/media/File:ModelsCatwalk.jpg
Cookstyle
http://a.fod4.com/images/user_photos/1356028/cea985e2ee743a14e6f466860b082381_width_640x.jpg
Foodcritic
https://pixabay.com/en/eyeglasses-exam-optometry-vision-2003188/#_=_
ChefSpec
Don’t Test Chef
Test Your Cookbook Logic
https://www.flickr.com/photos/freeloosedirt/2751535303
Test Kitchen
https://pixabay.com/en/clock-wall-clock-watch-time-old-1274699/
Great but takes forever
Kitchen Dokken
https://github.com/someara/kitchen-dokken
https://www.flickr.com/photos/ell-r-brown/20267645405/in/photostream/
InSpec
Please don’t just test ChefTest what’s important to your app
Simple Interfaces
Wrappable
All platforms supportedTested thoroughly
https://pixabay.com/en/police-car-auto-vehicle-city-210674/
Resources for help
https://www.flickr.com/photos/120920526@N08/15094478519
sous-chefs.org
Fresh New Chef Stuff on Youtube
Chef Community Slack
CfgMgmtCamp TalksMonday● Containers 14:00 - Monoliths, Myths, and Microservices
● Containers 16:20 - An upside-down Exploration of App Automation with Habitat
● Chef Room - 14:00 - Chef - Ask Me Anything (AMA)
● Chef Room - 14:40 - An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
● Chef Room - 15:40 - What's coming in Chef 13
● Chef Room - 16:20 - Building Better Community Cookbooks
● Chef Room - 17:00 - Chef, Microsoft, and Open Source: State of the Nation
Tuesday● Main Track 14:00 - Operating Systems are Assholes
● Future Tooling - 14:40 - Now That I Have Choreography, What Can I Do With It?
● Chef Room- 14:00 - Shared Services is Not a Field of Dreams
● Chef Room - 14:40 - CI/CD Workflows at Enterprise Sports Scale
● Chef Room -How to get the most of Foreman and Chef
● Main Track 16:20 - Food Fight Show