SlideShare a Scribd company logo
1 of 20
Download to read offline
Dive into CHEF
Eduardo S. Scarpellini
@escarpellini
Aug, 2016
Agenda
- Architecture;
- Main tools;
- Cooking;
- cookbooks, recipes, resources, templates, etc;
- Knife;
- LWRPs;
- Tests;
- Best practices;
Architecture
Main tools
● Development workstation:
○ chef-dk;
■ cookbook standardized skeletons, linting and testing tools, style checking;
○ knife;
■ swiss knife: cookbook/node management, search, many plugins (AWS, OpenStack,
VMWare, etc);
○ chef-kitchen (or any other testing tool);
■ runs acceptance criterias in a brand new/isolated environment (docker, vagrant, etc);
● Nodes:
○ chef-client;
○ ohai;
■ node attributes: platform and kernel details, network configuration, hostname, cpu and
memory data, etc;
Cookbook building blocks
● Metadata;
○ author, version, dependencies, documentation, etc;
● Resources;
○ desired state, several types (package, service), name+parameters, notifications/subscriptions;
● Attributes;
○ global hash table, precedence/override;
● Files and templates;
○ static or dynamic files (erb templates) that should be synchronized with nodes;
● Recipes;
○ collection of resources;
● Libraries, definitions and LWRPs;
○ custom resource types, ruby functions;
Cookbook anatomy
chef generate <cookbook, recipe, attribute, lwrp, ...>
attributes
files repository
recipes
templates repository
cookbook
Recipes: basics
● Ruby DSL;
● Collection of resources;
○ package, cookbook_file, directory,
template, service, execute, user,
group, cron, dsc_resource, etc.
● Interaction with attributes;
○ user defined or ohai;
● Everything is evaluated in the
same order that they are
declared;
● Can include other recipes;
{yum install …
apt-get install …
msiexec.exe /i …
type + name
}parameters
notification
{service …
systemctl …
sc.exe …
myapp/recipes/default.rb
Recipes: a bit more complex
ohai attribute
Powerful of Ruby: syntax,
variables, data structures,
conditionals, loopings,
libraries, gems, etc.
include external code
local variables
attribute
notification timer
Requires attribute definition:
myapp/recipes/default.rb
myapp/attributes/default.rb
Templates
ohai attributeCombine plain text with
Ruby code (<% … %>) for
variable substitution and
flow control. loop + attribute +
local variables
myapp/templates/default/haproxy.cfg.erb
myapp/attributes/default.rb
haproxy.cfg
What else...
● Attributes:
○ defined/accessed in/from attribute files, recipes, roles, environments and/or node JSONs;
○ precedence/overwritten (node.override > node.set > node.default);
○ accessed via node['key'] or node.key
● Data bags:
○ global variables stored as JSON files;
○ can be encrypted (suitable for passwords, shared keys, etc);
○ accessed via Chef::EncryptedDataBagItem.load('bag_name', 'bag_item')
● Roles describes nodes (group cookbooks, overwrite attributes);
● Nodes (JSON):
○ Node attributes (ohai + defined by cookbooks);
○ run_list: list (array) of roles, cookbooks and/or recipes that will run on the node.
Knife
● Provides an interface between a local chef-repo and the Chef server;
● Extensible;
● Helps to manage:
○ nodes:
■ knife node <create, edit, delete ,...>
○ cookbooks, roles and data bags:
■ knife cookbook <create, delete, upload, ...>
■ knife role <create, edit, delete, ...>
■ knife data bag <create, edit, delete, ...>
○ cloud/hypervisors/servers (plugins):
■ knife ec2 server create…
■ knife bootstrap <FQDN>…
LWRPs
● Is a simple extension of Chef;
● Is implemented as part of a cookbook;
● Follows easy, repeatable syntax patterns;
● Effectively leverages resources that are built into Chef;
● Is reusable in the same way as built-in resources;
LWRPs
myapp/providers/hello_world.rbmyapp/resources/hello_world.rb
resource parameter
usage:
resource name
resource action
resource
attributes
Kitchen
● Test cookbook data across any combination of platforms and test suites;
● Defined in a YAML file (.kitchen.yaml);
● Uses a driver plugin architecture;
○ many cloud providers and virtualization technologies
■ AWS, VMWare, Docker, Vagrant, openstack, etc;
○ automatic chef-server provisioning;
■ environments, roles, data bags, dependencies (via Berkshelf), etc;
● Supports all common testing frameworks that are used by the Ruby
community;
○ bats (bash), minitest, rspec, serverspec;
Kitchen will run all
.bats files against all
specified platforms
Kitchen
myapp/.kitchen.yml
test/integration/default/bats/lb_haproxy.bats
{
driver plugin
run_list +
attributes
bash commands
Kitchen
kitchen test
successful
fail
platform/instance
Best practices
● Plan in advance;
○ environments, roles, data bags and attributes hierarchy, naming conventions;
● Use foodcritic integrated to your favorite editor (sublime, atom);
● Versioning your cookbooks (at scm and at chef-server level);
○ use scm tags;
○ use one repository for each cookbook;
○ freeze stable versions on chef-server;
○ specify versions of the dependencies on metadata.rb;
○ specify versions of the application cookbooks either on roles or run_list;
● Use Berkshelf to manage your dependencies;
● Use search(...) instead hard-coded attributes whenever it's possible;
○ load-balancer members, cluster members, etc;
Best practices
● Build cookbooks that support external templates;
● Avoid repetition: use LWRPs;
● Don't reinvent the wheel: https://supermarket.chef.io/
○ don't fork;
○ build wrapper cookbooks that match your needs;
○ replace original templates when it's needed;
● Write/run tests;
○ rely on chef built-in resources and write tests only for your code;
● Let your CI tool take care of your publishing process;
○ checkout + run tests + version bump + cookbook upload;
Going further
● Getting started:
○ https://docs.chef.io/chef_overview.html
○ https://www.linode.com/docs/applications/chef/beginners-guide-chef
○ https://www.digitalocean.com/community/tutorial_series/getting-started-managing-your-infrastr
ucture-using-chef
● Books:
○ Chef Infrastructure Automation Cookbook;
○ Learning Chef: A Guide to Configuration Management and Automation
○ Customizing Chef;
Questions?

More Related Content

What's hot

Apache Dispatch
Apache DispatchApache Dispatch
Apache DispatchFred Moyer
 
SaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution ToolSaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution Toolinovex GmbH
 
Friends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFSFriends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFSSaumitra Srivastav
 
Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on awsEmanuel Calvo
 
Nsq & python worker
Nsq & python workerNsq & python worker
Nsq & python workerFelinx Lee
 
What's new in Luminous and Beyond
What's new in Luminous and BeyondWhat's new in Luminous and Beyond
What's new in Luminous and BeyondSage Weil
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with GlusterGluster.org
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto ExampleGluster.org
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layerKiyoto Tamura
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Gulcin Yildirim Jelinek
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisRizky Abdilah
 
Getting Started with Gulp
Getting Started with GulpGetting Started with Gulp
Getting Started with GulpJure Šuvak
 
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios
 
Install hadoop in a cluster
Install hadoop in a clusterInstall hadoop in a cluster
Install hadoop in a clusterXuhong Zhang
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOpsОмские ИТ-субботники
 
Large Scale Crawling with Apache Nutch and Friends
Large Scale Crawling with Apache Nutch and FriendsLarge Scale Crawling with Apache Nutch and Friends
Large Scale Crawling with Apache Nutch and Friendslucenerevolution
 
eZ Publish cluster unleashed revisited
eZ Publish cluster unleashed revisitedeZ Publish cluster unleashed revisited
eZ Publish cluster unleashed revisitedBertrand Dunogier
 
Automating with ansible (Part c)
Automating with ansible (Part c) Automating with ansible (Part c)
Automating with ansible (Part c) iman darabi
 

What's hot (20)

Apache Dispatch
Apache DispatchApache Dispatch
Apache Dispatch
 
SaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution ToolSaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution Tool
 
Friends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFSFriends of Solr - Nutch & HDFS
Friends of Solr - Nutch & HDFS
 
Pgbr 2013 postgres on aws
Pgbr 2013   postgres on awsPgbr 2013   postgres on aws
Pgbr 2013 postgres on aws
 
Nsq & python worker
Nsq & python workerNsq & python worker
Nsq & python worker
 
What's new in Luminous and Beyond
What's new in Luminous and BeyondWhat's new in Luminous and Beyond
What's new in Luminous and Beyond
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto Example
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layer
 
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
Managing PostgreSQL with Ansible - FOSDEM PGDay 2016
 
CoreOS Overview
CoreOS OverviewCoreOS Overview
CoreOS Overview
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Getting Started with Gulp
Getting Started with GulpGetting Started with Gulp
Getting Started with Gulp
 
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
 
Install hadoop in a cluster
Install hadoop in a clusterInstall hadoop in a cluster
Install hadoop in a cluster
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Large Scale Crawling with Apache Nutch and Friends
Large Scale Crawling with Apache Nutch and FriendsLarge Scale Crawling with Apache Nutch and Friends
Large Scale Crawling with Apache Nutch and Friends
 
eZ Publish cluster unleashed revisited
eZ Publish cluster unleashed revisitedeZ Publish cluster unleashed revisited
eZ Publish cluster unleashed revisited
 
Automating with ansible (Part c)
Automating with ansible (Part c) Automating with ansible (Part c)
Automating with ansible (Part c)
 

Viewers also liked

State of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCState of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCPuppet
 
Infrastructure Automation with Chef
Infrastructure Automation with Chef Infrastructure Automation with Chef
Infrastructure Automation with Chef REAN Cloud
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmersmrsabo
 
“Debugging is on the table” Dr. House pergunta a um Sysadmin
“Debugging is on the table”  Dr. House pergunta a um Sysadmin“Debugging is on the table”  Dr. House pergunta a um Sysadmin
“Debugging is on the table” Dr. House pergunta a um SysadminLeonardo Martins
 
Deploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode ChefDeploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode ChefRobert Berger
 
CPU Performance Enhancements
CPU Performance EnhancementsCPU Performance Enhancements
CPU Performance EnhancementsDilum Bandara
 
Chef Compliance & Workflow w/Delivery
Chef Compliance & Workflow w/Delivery Chef Compliance & Workflow w/Delivery
Chef Compliance & Workflow w/Delivery Chef
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Pravin Mishra
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
 
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 ChefChef Software, Inc.
 
(DVO301) AWS OpsWorks Under the Hood
(DVO301) AWS OpsWorks Under the Hood(DVO301) AWS OpsWorks Under the Hood
(DVO301) AWS OpsWorks Under the HoodAmazon Web Services
 
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...Docker, Inc.
 
Configuration Management with AWS OpsWorks - November 2016 Webinar Series
Configuration Management with AWS OpsWorks - November 2016 Webinar SeriesConfiguration Management with AWS OpsWorks - November 2016 Webinar Series
Configuration Management with AWS OpsWorks - November 2016 Webinar SeriesAmazon Web Services
 
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)Amazon Web Services
 

Viewers also liked (16)

State of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DCState of Puppet 2013 - Puppet Camp DC
State of Puppet 2013 - Puppet Camp DC
 
Infrastructure Automation with Chef
Infrastructure Automation with Chef Infrastructure Automation with Chef
Infrastructure Automation with Chef
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmers
 
“Debugging is on the table” Dr. House pergunta a um Sysadmin
“Debugging is on the table”  Dr. House pergunta a um Sysadmin“Debugging is on the table”  Dr. House pergunta a um Sysadmin
“Debugging is on the table” Dr. House pergunta a um Sysadmin
 
Training Opscode Chef
Training Opscode  ChefTraining Opscode  Chef
Training Opscode Chef
 
Etsy chef-workflow
Etsy chef-workflowEtsy chef-workflow
Etsy chef-workflow
 
Deploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode ChefDeploying infrastructure with Opscode Chef
Deploying infrastructure with Opscode Chef
 
CPU Performance Enhancements
CPU Performance EnhancementsCPU Performance Enhancements
CPU Performance Enhancements
 
Chef Compliance & Workflow w/Delivery
Chef Compliance & Workflow w/Delivery Chef Compliance & Workflow w/Delivery
Chef Compliance & Workflow w/Delivery
 
Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )Overview of chef ( Infrastructure as a Code )
Overview of chef ( Infrastructure as a Code )
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 Edition
 
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
 
(DVO301) AWS OpsWorks Under the Hood
(DVO301) AWS OpsWorks Under the Hood(DVO301) AWS OpsWorks Under the Hood
(DVO301) AWS OpsWorks Under the Hood
 
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
 
Configuration Management with AWS OpsWorks - November 2016 Webinar Series
Configuration Management with AWS OpsWorks - November 2016 Webinar SeriesConfiguration Management with AWS OpsWorks - November 2016 Webinar Series
Configuration Management with AWS OpsWorks - November 2016 Webinar Series
 
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
AWS re:Invent 2016: Configuration Management in the Cloud (DEV305)
 

Similar to Dive into Chef

Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and FriendsBen McRae
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef OpsworkHamza Waqas
 
Infrastructure modeling with chef
Infrastructure modeling with chefInfrastructure modeling with chef
Infrastructure modeling with chefCharles Johnson
 
lessons from managing a pulsar cluster
 lessons from managing a pulsar cluster lessons from managing a pulsar cluster
lessons from managing a pulsar clusterShivji Kumar Jha
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for OpenstackMohit Sethi
 
Introducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessIntroducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessRamit Surana
 
Orchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and MspectatorOrchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and MspectatorRaphaël PINSON
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Puppet
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and YouBryan Berry
 
Ceph Day Santa Clara: The Future of CephFS + Developing with Librados
Ceph Day Santa Clara: The Future of CephFS + Developing with LibradosCeph Day Santa Clara: The Future of CephFS + Developing with Librados
Ceph Day Santa Clara: The Future of CephFS + Developing with LibradosCeph Community
 
Let's Code our Infrastructure!
Let's Code our Infrastructure!Let's Code our Infrastructure!
Let's Code our Infrastructure!continuousphp
 
Introduction to Cooking with Chef
Introduction to Cooking with ChefIntroduction to Cooking with Chef
Introduction to Cooking with ChefJohn Osborne
 
SCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackSCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackMatt Ray
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefG. Ryan Fawcett
 

Similar to Dive into Chef (20)

Configuration management with Chef
Configuration management with ChefConfiguration management with Chef
Configuration management with Chef
 
Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and Friends
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef Opswork
 
Infrastructure modeling with chef
Infrastructure modeling with chefInfrastructure modeling with chef
Infrastructure modeling with chef
 
Chef for openstack
Chef for openstackChef for openstack
Chef for openstack
 
Chef advance
Chef advanceChef advance
Chef advance
 
Chef advance
Chef advanceChef advance
Chef advance
 
lessons from managing a pulsar cluster
 lessons from managing a pulsar cluster lessons from managing a pulsar cluster
lessons from managing a pulsar cluster
 
Chef for Openstack
Chef for OpenstackChef for Openstack
Chef for Openstack
 
Introducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomenessIntroducing Chef | An IT automation for speed and awesomeness
Introducing Chef | An IT automation for speed and awesomeness
 
Orchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and MspectatorOrchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and Mspectator
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
 
Chef, Devops, and You
Chef, Devops, and YouChef, Devops, and You
Chef, Devops, and You
 
Ceph Day Santa Clara: The Future of CephFS + Developing with Librados
Ceph Day Santa Clara: The Future of CephFS + Developing with LibradosCeph Day Santa Clara: The Future of CephFS + Developing with Librados
Ceph Day Santa Clara: The Future of CephFS + Developing with Librados
 
Chef fundamentals
Chef fundamentalsChef fundamentals
Chef fundamentals
 
Let's Code our Infrastructure!
Let's Code our Infrastructure!Let's Code our Infrastructure!
Let's Code our Infrastructure!
 
Introduction to Cooking with Chef
Introduction to Cooking with ChefIntroduction to Cooking with Chef
Introduction to Cooking with Chef
 
SCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStackSCALE12X: Chef for OpenStack
SCALE12X: Chef for OpenStack
 
LBNL Node Health Check Update
LBNL Node Health Check UpdateLBNL Node Health Check Update
LBNL Node Health Check Update
 
Cooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with ChefCooking 5 Star Infrastructure with Chef
Cooking 5 Star Infrastructure with Chef
 

Recently uploaded

FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Roomdivyansh0kumar0
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneCall girls in Ahmedabad High profile
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 

Recently uploaded (20)

FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 

Dive into Chef

  • 1. Dive into CHEF Eduardo S. Scarpellini @escarpellini Aug, 2016
  • 2. Agenda - Architecture; - Main tools; - Cooking; - cookbooks, recipes, resources, templates, etc; - Knife; - LWRPs; - Tests; - Best practices;
  • 4. Main tools ● Development workstation: ○ chef-dk; ■ cookbook standardized skeletons, linting and testing tools, style checking; ○ knife; ■ swiss knife: cookbook/node management, search, many plugins (AWS, OpenStack, VMWare, etc); ○ chef-kitchen (or any other testing tool); ■ runs acceptance criterias in a brand new/isolated environment (docker, vagrant, etc); ● Nodes: ○ chef-client; ○ ohai; ■ node attributes: platform and kernel details, network configuration, hostname, cpu and memory data, etc;
  • 5. Cookbook building blocks ● Metadata; ○ author, version, dependencies, documentation, etc; ● Resources; ○ desired state, several types (package, service), name+parameters, notifications/subscriptions; ● Attributes; ○ global hash table, precedence/override; ● Files and templates; ○ static or dynamic files (erb templates) that should be synchronized with nodes; ● Recipes; ○ collection of resources; ● Libraries, definitions and LWRPs; ○ custom resource types, ruby functions;
  • 6. Cookbook anatomy chef generate <cookbook, recipe, attribute, lwrp, ...> attributes files repository recipes templates repository cookbook
  • 7. Recipes: basics ● Ruby DSL; ● Collection of resources; ○ package, cookbook_file, directory, template, service, execute, user, group, cron, dsc_resource, etc. ● Interaction with attributes; ○ user defined or ohai; ● Everything is evaluated in the same order that they are declared; ● Can include other recipes; {yum install … apt-get install … msiexec.exe /i … type + name }parameters notification {service … systemctl … sc.exe … myapp/recipes/default.rb
  • 8. Recipes: a bit more complex ohai attribute Powerful of Ruby: syntax, variables, data structures, conditionals, loopings, libraries, gems, etc. include external code local variables attribute notification timer Requires attribute definition: myapp/recipes/default.rb myapp/attributes/default.rb
  • 9. Templates ohai attributeCombine plain text with Ruby code (<% … %>) for variable substitution and flow control. loop + attribute + local variables myapp/templates/default/haproxy.cfg.erb myapp/attributes/default.rb haproxy.cfg
  • 10. What else... ● Attributes: ○ defined/accessed in/from attribute files, recipes, roles, environments and/or node JSONs; ○ precedence/overwritten (node.override > node.set > node.default); ○ accessed via node['key'] or node.key ● Data bags: ○ global variables stored as JSON files; ○ can be encrypted (suitable for passwords, shared keys, etc); ○ accessed via Chef::EncryptedDataBagItem.load('bag_name', 'bag_item') ● Roles describes nodes (group cookbooks, overwrite attributes); ● Nodes (JSON): ○ Node attributes (ohai + defined by cookbooks); ○ run_list: list (array) of roles, cookbooks and/or recipes that will run on the node.
  • 11. Knife ● Provides an interface between a local chef-repo and the Chef server; ● Extensible; ● Helps to manage: ○ nodes: ■ knife node <create, edit, delete ,...> ○ cookbooks, roles and data bags: ■ knife cookbook <create, delete, upload, ...> ■ knife role <create, edit, delete, ...> ■ knife data bag <create, edit, delete, ...> ○ cloud/hypervisors/servers (plugins): ■ knife ec2 server create… ■ knife bootstrap <FQDN>…
  • 12. LWRPs ● Is a simple extension of Chef; ● Is implemented as part of a cookbook; ● Follows easy, repeatable syntax patterns; ● Effectively leverages resources that are built into Chef; ● Is reusable in the same way as built-in resources;
  • 14. Kitchen ● Test cookbook data across any combination of platforms and test suites; ● Defined in a YAML file (.kitchen.yaml); ● Uses a driver plugin architecture; ○ many cloud providers and virtualization technologies ■ AWS, VMWare, Docker, Vagrant, openstack, etc; ○ automatic chef-server provisioning; ■ environments, roles, data bags, dependencies (via Berkshelf), etc; ● Supports all common testing frameworks that are used by the Ruby community; ○ bats (bash), minitest, rspec, serverspec;
  • 15. Kitchen will run all .bats files against all specified platforms Kitchen myapp/.kitchen.yml test/integration/default/bats/lb_haproxy.bats { driver plugin run_list + attributes bash commands
  • 17. Best practices ● Plan in advance; ○ environments, roles, data bags and attributes hierarchy, naming conventions; ● Use foodcritic integrated to your favorite editor (sublime, atom); ● Versioning your cookbooks (at scm and at chef-server level); ○ use scm tags; ○ use one repository for each cookbook; ○ freeze stable versions on chef-server; ○ specify versions of the dependencies on metadata.rb; ○ specify versions of the application cookbooks either on roles or run_list; ● Use Berkshelf to manage your dependencies; ● Use search(...) instead hard-coded attributes whenever it's possible; ○ load-balancer members, cluster members, etc;
  • 18. Best practices ● Build cookbooks that support external templates; ● Avoid repetition: use LWRPs; ● Don't reinvent the wheel: https://supermarket.chef.io/ ○ don't fork; ○ build wrapper cookbooks that match your needs; ○ replace original templates when it's needed; ● Write/run tests; ○ rely on chef built-in resources and write tests only for your code; ● Let your CI tool take care of your publishing process; ○ checkout + run tests + version bump + cookbook upload;
  • 19. Going further ● Getting started: ○ https://docs.chef.io/chef_overview.html ○ https://www.linode.com/docs/applications/chef/beginners-guide-chef ○ https://www.digitalocean.com/community/tutorial_series/getting-started-managing-your-infrastr ucture-using-chef ● Books: ○ Chef Infrastructure Automation Cookbook; ○ Learning Chef: A Guide to Configuration Management and Automation ○ Customizing Chef;