Building Better Chef Community Cookbooks

73
Tim Smith - @tas50 Community Engineer, Chef Building Better Community Cookbooks https://www.pexels.com/photo/mountains-under-cloudy-sky-during-daytime-168865/

Transcript of Building Better Chef Community Cookbooks

Page 1: 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/

Page 2: Building Better Chef Community Cookbooks

https://pixabay.com/en/clock-wall-clock-brick-wall-old-1250204/

Let’s Start With a Little Story

Page 3: Building Better Chef Community Cookbooks

Hypothetical Sysadmin

New to Chef

New to Ruby

New to this DevOps thing

Page 4: Building Better Chef Community Cookbooks

Lets call him 2011 Tim

New to Chef

New to Ruby

New to this DevOps thing

Hypothetical Sysadmin

Page 5: Building Better Chef Community Cookbooks

Tim’s first community cookbook experience

https://www.flickr.com/photos/statefarm/10994875346

Page 6: Building Better Chef Community Cookbooks

My Boss Circa 2011

We need a monitoring system. Go build one and

have it done… this week!

Page 7: Building Better Chef Community Cookbooks

Couldn’t be that hard….

Page 8: Building Better Chef Community Cookbooks

Chef Will Solve Everything

Page 9: Building Better Chef Community Cookbooks

Maybe not…

Page 10: Building Better Chef Community Cookbooks

Oh Wait No RHEL Support

Page 11: Building Better Chef Community Cookbooks

Time to get hacking

https://www.flickr.com/photos/132889348@N07/20607150556

Page 12: Building Better Chef Community Cookbooks

Time to get hacking

https://www.flickr.com/photos/132889348@N07/20607150556

This is basically what ruby looked like to me

Page 13: Building Better Chef Community Cookbooks

Way Too Much Time Later

https://en.wikipedia.org/wiki/Father_Time#/media/File:Romanelli_Chronos_and_his_child.jpg

Page 14: Building Better Chef Community Cookbooks

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

Page 15: Building Better Chef Community Cookbooks

https://www.flickr.com/photos/number7cloud/28013072643

Page 16: Building Better Chef Community Cookbooks

Where are all my nodes?

Page 17: Building Better Chef Community Cookbooks

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

Page 18: Building Better Chef Community Cookbooks

A lot of commits later

Page 19: Building Better Chef Community Cookbooks

In the end we had a great cookbookbut the project was a failure

Page 20: Building Better Chef Community Cookbooks

So what did I learn from all this?

http://www.publicdomainpictures.net/view-image.php?image=182073&picture=antique-wood-school-desk

Page 21: Building Better Chef Community Cookbooks

https://commons.wikimedia.org/wiki/File:2010_0515_rama_4_and_sathorn_22a.JPG

Community cookbooks are a tire fire right?

Page 22: Building Better Chef Community Cookbooks

https://www.flickr.com/photos/bitterjug/7670055210

NoIt’s more complicated than that

Page 23: Building Better Chef Community Cookbooks

3000+ Cookbooks7000+ Users

https://en.wikipedia.org/wiki/Supermarket#/media/File:Fredmeyer_edit_1.jpg

Page 24: Building Better Chef Community Cookbooks

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

Page 25: Building Better Chef Community Cookbooks

Some cookbooks are community cookbooks; others are just shared code

https://www.flickr.com/photos/huangjiahui/2893120846

Page 26: Building Better Chef Community Cookbooks

How do we write community cookbooks and not shared code?

https://www.flickr.com/photos/wlodi/3152672560

Page 27: Building Better Chef Community Cookbooks

Community cookbooks are not enterprise cookbooks

https://upload.wikimedia.org/wikipedia/commons/b/b5/VulcanAlbertaEnterpriseReplica.jpg

Page 28: Building Better Chef Community Cookbooks

CommunityCookbook

EnterpriseCookbook

Usage Pattern, Platform Support, Tuneables, etc

Page 29: Building Better Chef Community Cookbooks

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

Page 30: Building Better Chef Community Cookbooks

S

W

A T

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 31: Building Better Chef Community Cookbooks

Simple Interfaces

Wrappable

All platforms supportedTested thoroughly

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 32: Building Better Chef Community Cookbooks

Simple Interfaces

W

A T

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 33: Building Better Chef Community Cookbooks

Technology is hard. Your cookbook shouldn’t be harder

Page 34: Building Better Chef Community Cookbooks

Interface Patterns to Avoid

Large numbers of attributes

Clever abstraction models only you understand

Trying to parameterize the impossible

Page 35: Building Better Chef Community Cookbooks

Understanding Simple Interfaces

Page 36: Building Better Chef Community Cookbooks

Components of a Simple Cookbook

App Binary

Config

Service Management

Page 37: Building Better Chef Community Cookbooks

App Binary

Config

Service Management

Components of a Complex Cookbook

Page 38: Building Better Chef Community Cookbooks

Cookbook components map to Custom Resources nicely

Page 39: Building Better Chef Community Cookbooks

App Binary

Config

Service Management

foo_install

foo_config

foo_service

Component to Custom Resource Mapping

Page 40: Building Better Chef Community Cookbooks

Don’t jump into code. Write test recipe firstThat’s your design

Page 41: Building Better Chef Community Cookbooks

Think about how YOU would want to consume the resources

It’s the hard right thing

Page 42: Building Better Chef Community Cookbooks

Example Test Recipe

Page 43: Building Better Chef Community Cookbooks

S

Wrappable

A T

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 44: Building Better Chef Community Cookbooks

Turn key cookbooks never work2011 Opscode lied to you

Page 45: Building Better Chef Community Cookbooks

Design Patterns to Avoid

Highly opinionated end to end cookbooks

Monolithic recipes (or recipes altogether)

Opinionated dependency installs (ruby, java, etc)

Page 46: Building Better Chef Community Cookbooks

Sample Wrapper Usage PatternsGood and Better Designs

Page 47: Building Better Chef Community Cookbooks

Basic Wrapper

Page 48: Building Better Chef Community Cookbooks

Better Wrapper

Page 49: Building Better Chef Community Cookbooks

S

W

All platforms supportedT

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 50: Building Better Chef Community Cookbooks

All Platforms Supported

Someone somewhere is going to want Gentoo support

Richard Stallman…loves that laptop apparently

Page 51: Building Better Chef Community Cookbooks

S

W

A Tested thoroughly

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 52: Building Better Chef Community Cookbooks

Do you test your changes?On every platform?

Every single commit?

https://upload.wikimedia.org/wikipedia/commons/4/47/StateLibQld_1_100348.jpg

Page 53: Building Better Chef Community Cookbooks

https://upload.wikimedia.org/wikipedia/commons/4/47/StateLibQld_1_100348.jpg

You need automated testing

Page 54: Building Better Chef Community Cookbooks

What to test though?

https://upload.wikimedia.org/wikipedia/commons/4/47/StateLibQld_1_100348.jpg

Page 55: Building Better Chef Community Cookbooks

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

Page 56: Building Better Chef Community Cookbooks

https://en.wikipedia.org/wiki/Runway_(fashion)#/media/File:ModelsCatwalk.jpg

Cookstyle

Page 57: Building Better Chef Community Cookbooks

http://a.fod4.com/images/user_photos/1356028/cea985e2ee743a14e6f466860b082381_width_640x.jpg

Foodcritic

Page 58: Building Better Chef Community Cookbooks

https://pixabay.com/en/eyeglasses-exam-optometry-vision-2003188/#_=_

ChefSpec

Page 59: Building Better Chef Community Cookbooks

Don’t Test Chef

Page 60: Building Better Chef Community Cookbooks

Test Your Cookbook Logic

Page 61: Building Better Chef Community Cookbooks

https://www.flickr.com/photos/freeloosedirt/2751535303

Test Kitchen

Page 62: Building Better Chef Community Cookbooks
Page 63: Building Better Chef Community Cookbooks
Page 64: Building Better Chef Community Cookbooks

https://pixabay.com/en/clock-wall-clock-watch-time-old-1274699/

Great but takes forever

Page 65: Building Better Chef Community Cookbooks

Kitchen Dokken

https://github.com/someara/kitchen-dokken

Page 66: Building Better Chef Community Cookbooks
Page 67: Building Better Chef Community Cookbooks

https://www.flickr.com/photos/ell-r-brown/20267645405/in/photostream/

InSpec

Page 68: Building Better Chef Community Cookbooks

Please don’t just test ChefTest what’s important to your app

Page 69: Building Better Chef Community Cookbooks
Page 70: Building Better Chef Community Cookbooks
Page 71: Building Better Chef Community Cookbooks

Simple Interfaces

Wrappable

All platforms supportedTested thoroughly

https://pixabay.com/en/police-car-auto-vehicle-city-210674/

Page 72: Building Better Chef Community Cookbooks

Resources for help

https://www.flickr.com/photos/120920526@N08/15094478519

sous-chefs.org

Fresh New Chef Stuff on Youtube

Chef Community Slack

Page 73: Building Better Chef Community Cookbooks

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