Cooking with Chef

Sergiu Vidrascu

Who am I ?

Ce e chef???

  • Infrastructure automation tool
  • Target users > Dev/SYS
  • Aim -> Continuosly define, build and manage infrastructure
  • Model promotes reuse
  • Ruby based

Overall Architecture

 

  • Development Kit (FREE)



     
  • Server (FREE)




     
  • Client (Agent) (FREE)

Chef Learning Curve

My first Attempts of building a chef cookbook

Anatomia unui run de chef ??

Chef-client 

build node 

Sync cookbooks

Incarcarea cookbookurilor

Text

Converge 

Success?

Report handles

Da

Exception Handlers

Nu

Anatomia unui run de chef ??

Chef-client 

  • Agentul folosit the chef
  • Se poate conecta la un server sau nu
  • Se poate instala pe majoritatea OS-urilor - https://downloads.chef.io/chef-client/

Chef-client 

Construirea nodului:

  • Ohai -> Profiling la sistemul de operare
  • Autentificarea la serverul chef daca exista
  • Formarea Obiectului de tip Node (attributes & run list)

build node 

Anatomia unui run de chef ??

Chef-client 

Syncronizarea cookbookurilor

  • Se citeste fisierul metadata din cookbookurile folosite si se rezolva dependintele
  • Daca run-ul e  fara server trebuie sa fie totul deja pe masina
  • Daca se foloseste serverul atunci se face download de pe server

build node 

Sync cookbooks

Anatomia unui run de chef ??

Chef-client 

build node 

Sync cookbooks

Incarcarea cookbookurilor

Ordinea de incarcare:

  • Libraries
  • Providers
  • Resources
  • Attributes
  • Definitions
  • Recipes

Templates & cookbook files are not loaded here 

Anatomia unui run de chef ??

Chef-client 

build node 

Sync cookbooks

Incarcarea cookbookurilor

Text

Converge 

Anatomia unui run de chef ??

Chef-client 

build node 

Sync cookbooks

Incarcarea cookbookurilor

Text

Converge 

Success?

Anatomia unui run de chef ??

Chef-client 

build node 

Sync cookbooks

Incarcarea cookbookurilor

Text

Converge 

Success?

Report handles

Da

Anatomia unui run de chef ??

Chef-client 

build node 

Sync cookbooks

Incarcarea cookbookurilor

Text

Converge 

Success?

Report handles

Da

Exception Handlers

Nu

Anatomia unui run de chef ??

Cum arata un cookbook + Demo

Pros:

 - Templates

 - Using ruby code for custom functionality

 - Defining your own resources

 - Brilliant Testing Capabilities out of the box

 - Did i mention it's FREE

 - Awesome community

 - Good documentation

 - Idempotency

 - A lot of flexibility and control when using Chef Server

Cons / Issues I've encountered:

 - Derived attributes

 - Using Attributes in custom-resources

 - Windows vs Linux (Boom)

 - Not so Reusable resources across every platform (ex: execute)

 - If not built right, quite slow, mainly because of all the downloads (dependency download) and the pure fact that it uses an agent

Q & A

Cooking with Chef

By Sergiu Vidrascu