chefconf 2016 - writing compossible community cookbooks using chef custom resources

96
Tim Smith - @tas50 Community Engineer, Chef Writing Compossible Community Cookbooks using Chef Custom Resources

Upload: timothy-smith

Post on 07-Jan-2017

283 views

Category:

Technology


0 download

TRANSCRIPT

  • Tim Smith - @tas50 Community Engineer, Chef

    Writing Compossible Community Cookbooks using Chef Custom Resources

  • A Community Cookbook Origin Story

    https://www.flickr.com/photos/pesotum/171923662

  • Ops we need MyFace deployed by

    end of day!

    https://upload.wikimedia.org/wikipedia/commons/9/9a/Meeting_in_Air_Force_One_conference_room.jpg

  • http://joebideneatsicecream.tumblr.com/

    No worries Ill whip it up in Chef

    Salt and Straw is way expensive

  • https://en.wikipedia.org/wiki/Cycling#/media/File:Leon_Georget_1909.jpg

    v1.0: Simple and Elegant Design

  • https://www.flickr.com/photos/christopheducamp/7463696734

    I Should Share This!

  • http://www.slate.com/content/dam/slate/articles/news_and_politics/politics/2015/05/150519_POL_MissionAccomplished.jpg.CROP.promovar-mediumlarge.jpg

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

  • Uh Oh

  • https://upload.wikimedia.org/wikipedia/commons/thumb/6/69/Richard_Stallman_by_Anders_Brenna_03.jpg/1280px-Richard_Stallman_by_Anders_Brenna_03.jpg

    Time to Put On My Maintainer Hat

  • Things Are About to Get Weird

    https://en.wikipedia.org/wiki/Penny-farthing#/media/File:Pennyfarthing-1886.jpg

  • https://en.wikipedia.org/wiki/Smoke_screen#/media/File:2010_0515_rama_4_and_sathorn_22a.JPG

  • https://en.wikipedia.org/wiki/Smoke_screen#/media/File:2010_0515_rama_4_and_sathorn_22a.JPG

    Database cookbook

  • How Do We Right the Ship

    https://upload.wikimedia.org/wikipedia/commons/b/b6/Cougar_Ace_on_side_%28starboard_side%29.jpg

  • Scrap it and Start Over

  • Apache Tomcat

  • Quick Sidebar

  • Oh Geez Not Tomcat?

  • I hate Java!

  • All the cool kids write JS

  • https://www.flickr.com/photos/jamescridland/613445810

  • https://www.flickr.com/photos/jamescridland/613445810

    Me

  • https://www.flickr.com/photos/jamescridland/613445810

    MeYou

  • https://www.flickr.com/photos/jamescridland/613445810

    Blah BlahTomcat Blah Blah Blah Blah Blah Blah

  • https://www.flickr.com/photos/jamescridland/613445810

    Blah BlahTomcat Blah Blah Blah Blah Blah Blah

    Node

  • https://www.flickr.com/photos/jamescridland/613445810

    Blah BlahTomcat Blah Blah Blah Blah Blah Blah

    Node Rust

  • Web Stuff

    JAVA XML

    pixabay.com & Wikimedia Commons

    Tomcat 101

    http://pixabay.com

  • End Sidebar(I told you itd be quick)

  • Why is Tomcat Such a Great Example

    https://pixabay.com/en/cat-siberian-tomcat-1086330/

  • https://pixabay.com/en/ruins-pretoria-building-stones-664869/

    It Was Completely Falling Apart

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

    It Attempted to Automate Complex Software

  • pixabay.com

    It Used a Rigid Monolithic Design

  • Matt Groening

    It Followed the Natural Cookbook Progression

  • https://upload.wikimedia.org/wikipedia/commons/7/79/Operation_Upshot-Knothole_-_Badger_001.jpg

    Nuke it and Start Over Right?

  • https://www.flickr.com/photos/39908901@N06/13963173985

    Nope. Lets Think This Through

  • What should a community cookbook look like?

    Community Tomcat vs. In House Tomcat Cookbook Scope

    Pre-rewrite Checklist

    What are the building blocks of a Tomcat Cookbook?

  • Whats the Job of a Community Cookbook Anyways?

    https://static.pexels.com/photos/56002/pexels-photo-56002.jpeg

  • Provide simple interfaces to compossible resources that empower users to write their own cookbooks which aid in the automation of

    highly customized and complex software environments

    Source: Me

    Community cookbooks should:

  • simple interfaces

    https://en.wikipedia.org/wiki/History_of_Lego#/media/File:Lego_dublo_arto_alanenpaa_5.JPG

  • compossible resources

    https://pixabay.com/en/lego-lego-duplo-building-built-190704/

  • empower users to write their own cookbooks

    https://www.flickr.com/photos/mr_t_in_dc/4766284256

  • highly customized and complex software environments

    https://pixabay.com/en/lego-legoland-legostadt-186034/

  • What should a community cookbook look like?

    Community Tomcat vs. In House Tomcat Cookbook Scope

    Pre-rewrite Checklist

    What are the building blocks of a Tomcat Cookbook?

  • Community Tomcat vs. Private Tomcat Cookbook Scope

    https://commons.wikimedia.org/wiki/File:2_duplo_lego_bricks.jpg

  • MyCorp Tomcat Community Tomcat

    Usage pattern Opinionated Flexible

    Platform Support Single Platform (usually) Multi-platform

    Tuneables Limited Every possible thing

  • MyCorp Tomcat Community Tomcat

    Usage pattern Opinionated Flexible

    Platform Support Single Platform (usually) Multi-platform

    Tuneables Limited Every possible thing

  • MyCorp Tomcat Community Tomcat

    Usage pattern Opinionated Flexible

    Platform Support Single Platform (usually) Multi-platform

    Tuneables Limited Every possible thing

  • MyCorp Tomcat Community Tomcat

    Usage pattern Opinionated Flexible

    Platform Support Single Platform (usually) Multi-platform

    Tuneables Limited Every possible thing

  • What should a community cookbook look like?

    Community Tomcat vs. In House Tomcat Cookbook Scope

    Pre-rewrite Checklist

    What are the building blocks of a Tomcat Cookbook?

  • What are the building blocks of a Tomcat Cookbook?

    https://en.wikipedia.org/wiki/Lego#/media/File:Lego_Color_Bricks.jpg

  • App Binary

    Config

    Service Management

    Components of a Simple Cookbook

  • App Binary

    Config

    Service Management

    tomcat_install

    tomcat_config?

    tomcat_service

    Component to Custom Resource Mapping

  • tomcat_install scope

    Fetch artifact Specify a version Install artifact to directory Set user / group permissions on the install

  • Time to Generate the Cookbook

  • Even More Important

  • Install Your App Binary

  • tomcat_config scope

    Allow passing a monolithic XML config blob in via Ruby.

    Pretty sure this isnt possible. Good PRs accepted!

  • Test Recipe is Your Design

  • tomcat_service scope

    Install init script / config Allow start/stop/restart/enable actions on the service Work with sys-v, upstart, systemd init

  • Define Your Service

  • Put it All Together

  • What should a community cookbook look like?

    Community Tomcat vs. In House Tomcat Cookbook Scope

    Pre-rewrite Checklist

    What are the building blocks of a Tomcat Cookbook?

  • Custom Resource Time

    https://en.wikipedia.org/wiki/Lego#/media/File:Lego_Color_Bricks.jpg

  • Basic Custom Resource

    Properties: Variables you pass in

    Actions: One or more things the resource can do

    Provides: Name of the resource and a distro to run it on (optional)

    Action Class: Helper methods for use in the actions (optional, but handy)

  • Create the Resource

  • Example of Properties

  • Example of Actions

  • Example of Action Class

  • Example of Provides

  • service_sysv_init.rb

    service_upstart.rb

    service_systemd.rb

    tomcat_service to Init Mapping

    RHEL < 7 Amazon Linux SUSE < 13 Debian < 8

    Ubuntu < 15.10

    Debian 8+ SUSE 13+ Ubuntu 16.04+ RHEL 7+ Fedora

  • Provides is Magic

  • http://i.bullfax.com/imgs/3d20fd81ba73b7479088e77b363a5a1e690b3e52.jpg

    Platform Support is Done!

  • http://i.bullfax.com/imgs/3d20fd81ba73b7479088e77b363a5a1e690b3e52.jpg

    Oh We Forgot That One Platform

  • http://i.bullfax.com/imgs/3d20fd81ba73b7479088e77b363a5a1e690b3e52.jpg

    PRs Welcome

  • one more thing

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

    Lets Test This Thing

  • 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://www.flickr.com/photos/ell-r-brown/20267645405/in/photostream/

    InSpec

  • Simple Inspec Tests

  • Test Kitchen To Tie It All Together

  • Test It All

  • Kitchen-dokken in Travis CI is Also Magic

  • Design

    Test Cookbook

    Resources

    Testing

    Awesomeness

  • Read the Docs For More Cool Stuff

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

    https://docs.chef.io/custom_resources.html