SlideShare a Scribd company logo
1 of 32
Download to read offline
chef-client
Applying Recipes from Cookbooks
Slide 1 of 32
After completing this module, you should be able to use
chef-client to:
Locally apply a cookbook's recipe with chef-client.
Locally apply multiple cookbooks' recipes with chef-
client.
Include a recipe from within another recipe.
Objectives
Slide 2 of 32
chef-apply is a great tool for applying resources (-e)
and for individual recipes but it doesn't know how to
apply a cookbook.
chef-apply
https://docs.chef.io/ctl_chef_apply.html
Slide 3 of 32
chef-client is an agent that runs locally on every node
that is under management by Chef.
When a chef-client is run, it will perform all of the
steps that are required to bring the node into the
expected state.
chef-client
https://docs.chef.io/chef_client.html
Slide 4 of 32
chef-client's default mode attempts to contact a Chef
Server and ask it for the recipes to run for the given
node.
We are overriding that behavior to have it work in a
local mode.
--local-mode
Slide 5 of 32
In local mode, we need to provide a list of recipes to
apply to the system. This is called a run list. A run list
is an ordered collection of recipes to execute.
Each recipe in the run list must be addressed with the
format recipe[cookbook-name::recipe-name].
-r "recipe[cookbook-name::recipe-name]"
Slide 6 of 32
When you are referencing the default recipe within a
cookbook you may optionally specify only the name of
the cookbook.
chef-client understands that you mean to apply the
default recipe from within that cookbook.
-r "recipe[cookbook-name(::default)]"
Slide 7 of 32
Example Usage
Using chef-client to locally apply the setup recipe from the workstation
cookbook.
$sudochef-client--local-mode–r"recipe[workstation::setup]"
Applyingthefollowingrecipeslocally:
The'setup'recipefromthe'workstation'cookbook
Slide 8 of 32
Example Usage
Using chef-client to locally apply the server recipe from the apache cookbook.
$sudochef-client--local-mode-r"recipe[apache::server]"
Applyingthefollowingrecipeslocally:
The'server'recipefromthe'apache'cookbook
Slide 9 of 32
Example Usage
Using chef-client to locally apply multiple recipes from multiple cookbooks.
$sudochef-client--local-mode
-r"recipe[workstation::setup],recipe[apache::server]"
Applyingthefollowingrecipeslocally:
*The'setup'recipefromthe'workstation'cookbook
*The'server'recipefromthe'apache'cookbook
Slide 10 of 32
Group Exercise: Return Home First
$cd~
Slide 11 of 32
Group Exercise: Apply the apache::server Recipe Locally
$sudochef-client--local-mode-r"recipe[apache::server]"
[2015-09-15T14:52:45+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
[2015-09-15T14:52:45+00:00]WARN:Nocookbooksdirectoryfoundatorabovecurrentdirectory. Assuming/home/chef.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["apache::server"]
================================================================================
ErrorResolvingCookbooksforRunList:
================================================================================
Slide 12 of 32
Group Exercise: Apply the apache::server Recipe Locally
$sudochef-client--local-mode-r"recipe[apache::server]"
[2015-09-15T14:52:45+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
[2015-09-15T14:52:45+00:00]WARN:Nocookbooksdirectoryfoundatorabovecurrentdirectory. Assuming/home/chef.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["apache::server"]
================================================================================
ErrorResolvingCookbooksforRunList:
================================================================================
FAIL
Slide 13 of 32
Group Exercise: Create a cookbooks directory
chef-client requires the cookbooks to be in a cookbooks directory located
in the user's home directory.
$cd~
$mkdircookbooks
$mvworkstationcookbooks
$mvapachecookbooks
Slide 14 of 32
Group Exercise: Apply the apache::server Recipe Locally
$sudochef-client--local-mode-r"recipe[apache::server]"
[2015-09-15T14:54:45+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["apache::server"]
SynchronizingCookbooks:
-apache
CompilingCookbooks...
Converging4resources
Recipe:apache::server
*yum_package[httpd]actioninstall(uptodate)
*file[/var/www/html/index.html]actioncreate(uptodate)
*service[httpd]actionenable(uptodate)
Slide 15 of 32
Group Exercise: Apply the workstation::setup Recipe Locally
$sudochef-client--local-mode-r"recipe[workstation::setup]"
[2015-09-15T15:15:26+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["workstation::setup"]
SynchronizingCookbooks:
-workstation
CompilingCookbooks...
Converging6resources
Recipe:workstation::setup
*yum_package[nano]actioninstall(uptodate)
*yum_package[vim]actioninstall(uptodate)
*yum_package[emacs]actioninstall(uptodate)
Slide 16 of 32
Group Exercise: Apply Both Recipes Locally
$sudochef-client--local-mode
-r"recipe[apache::server],recipe[workstation::setup]"
[2015-09-15T15:17:27+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["apache::server","workstation::setup"]
SynchronizingCookbooks:
-apache
-workstation
CompilingCookbooks...
Runninghandlers:
[2015-09-15T15:17:30+00:00]ERROR:Runningexceptionhandlers
Runninghandlerscomplete
Slide 17 of 32
A recipe can include one (or more) recipes located in
cookbooks by using the include_recipemethod.
When a recipe is included, the resources found in that
recipe will be inserted (in the same exact order) at the
point where the include_recipekeyword is located.
include_recipe
https://docs.chef.io/recipes.html#include-recipes
Slide 18 of 32
Example Usage: Including a Recipe
Include the setup recipe from the workstation cookbook in this recipe.
include_recipe'workstation::setup'
Slide 19 of 32
Example Usage: Including a recipe
Include the server recipe from the apache cookbook in this recipe.
include_recipe'apache::server'
Slide 20 of 32
Group Exercise: The default recipe includes the setup recipe
~/cookbooks/workstation/recipes/default.rb
#
#CookbookName::workstation
#Recipe::default
#
#Copyright(c)2015TheAuthors,AllRightsReserved.
include_recipe'workstation::setup'
Slide 21 of 32
Group Exercise: Apply the cookbook's default recipe
$sudochef-client--local-mode-r"recipe[workstation]"
WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["workstation"]
SynchronizingCookbooks:
-workstation
CompilingCookbooks...
Converging0resources
Runninghandlers:
Runninghandlerscomplete
ChefClientfinished,0/0resourcesupdatedin3.300489827seconds
Slide 22 of 32
Group Exercise: Commit Your Work
$cdworkstation
$gitadd.
$gitcommit-m"Defaultrecipeincludesthesetuprecipe"
Slide 23 of 32
Update the apache cookbook's default recipe to:
Include the server recipe from the
apache cookbook
Run chef-client and locally apply the run list:
recipe[apache]
Commit the changes with version control
Lab: Update the apache Cookbook
Slide 24 of 32
Lab: The default recipe includes the apache recipe
~/cookbooks/apache/recipes/default.rb
#
#CookbookName::apache
#Recipe::default
#
#Copyright(c)2015TheAuthors,AllRightsReserved.
include_recipe'apache::server'
Slide 25 of 32
Lab: Applying the apache default recipe
$sudochef-client--local-mode-r"recipe[apache]"
[2015-09-15T15:23:18+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions.
StartingChefClient,version12.3.0
resolvingcookbooksforrunlist:["apache"]
SynchronizingCookbooks:
-apache
CompilingCookbooks...
Converging0resources
Runninghandlers:
Runninghandlerscomplete
ChefClientfinished,0/0resourcesupdatedin3.310768509seconds
Slide 26 of 32
Lab: Commit Your Work
$cdapache
$gitadd.
$gitcommit-m"Defaultrecipeincludestheserverrecipe"
Slide 27 of 32
Why would you want to apply more than one recipe at
a time?
Discussion
Slide 28 of 32
Why would you want to apply more than one recipe at
a time?
What are the benefits and drawbacks of using
include_recipewithin a recipe?
Discussion
Slide 29 of 32
Why would you want to apply more than one recipe at
a time?
What are the benefits and drawbacks of using
include_recipewithin a recipe?
Do default values make it easier or harder to learn?
Discussion
Slide 30 of 32
Q&A
What questions can we help you answer?
chef-client
local mode
run list
include_recipe
Slide 31 of 32
On to Module 5
Slide 32 of 32

More Related Content

What's hot

Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerMandi Walls
 
Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Sean OMeara
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for DevelopersAntons Kranga
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Automating Large Applications on Modular and Structured Form with Gulp
Automating Large Applications on Modular and Structured Form with GulpAutomating Large Applications on Modular and Structured Form with Gulp
Automating Large Applications on Modular and Structured Form with GulpAnderson Aguiar
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.jsBo-Yi Wu
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
Cooking Perl with Chef
Cooking Perl with ChefCooking Perl with Chef
Cooking Perl with ChefDavid Golden
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazelNatan Silnitsky
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」Tsuyoshi Yamamoto
 
Writing a Jenkins / Hudson plugin
Writing a Jenkins / Hudson pluginWriting a Jenkins / Hudson plugin
Writing a Jenkins / Hudson pluginAnthony Dahanne
 
2. auto deploy to tomcat on jenkins
2. auto deploy to tomcat on jenkins2. auto deploy to tomcat on jenkins
2. auto deploy to tomcat on jenkinsHuang Bruce
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupalAndrii Podanenko
 

What's hot (20)

Chef training Day4
Chef training Day4Chef training Day4
Chef training Day4
 
Chef training Day5
Chef training Day5Chef training Day5
Chef training Day5
 
Chef training - Day3
Chef training - Day3Chef training - Day3
Chef training - Day3
 
Chef training - Day2
Chef training - Day2Chef training - Day2
Chef training - Day2
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
 
Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Automating Large Applications on Modular and Structured Form with Gulp
Automating Large Applications on Modular and Structured Form with GulpAutomating Large Applications on Modular and Structured Form with Gulp
Automating Large Applications on Modular and Structured Form with Gulp
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.js
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Cooking Perl with Chef
Cooking Perl with ChefCooking Perl with Chef
Cooking Perl with Chef
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazel
 
Welcome to Jenkins
Welcome to JenkinsWelcome to Jenkins
Welcome to Jenkins
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
 
Writing a Jenkins / Hudson plugin
Writing a Jenkins / Hudson pluginWriting a Jenkins / Hudson plugin
Writing a Jenkins / Hudson plugin
 
2. auto deploy to tomcat on jenkins
2. auto deploy to tomcat on jenkins2. auto deploy to tomcat on jenkins
2. auto deploy to tomcat on jenkins
 
Lviv 2013 d7 vs d8
Lviv 2013   d7 vs d8Lviv 2013   d7 vs d8
Lviv 2013 d7 vs d8
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
 

Similar to Chef for beginners module 4

Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Chef
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbookdevopsjourney
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Chef
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Chef
 
Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)Mischa Taylor
 
Chef basics - write infrastructure as code
Chef basics - write infrastructure as codeChef basics - write infrastructure as code
Chef basics - write infrastructure as codestevaaa
 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Chef
 
Cooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugDavid Golden
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlabChef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to ChefKnoldus Inc.
 
Using Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksUsing Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksTimur Batyrshin
 
Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2Sylvain Tissot
 
Cookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecCookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecDaniel Paulus
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef OpsworkHamza Waqas
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Patrick McDonnell
 
Ignite Talk on Chef
Ignite Talk on ChefIgnite Talk on Chef
Ignite Talk on ChefBob Nowadly
 
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and ServerspecTest Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and ServerspecYury Tsarev
 

Similar to Chef for beginners module 4 (20)

Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
Community Cookbooks & further resources - Fundamentals Webinar Series Part 6
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4
 
Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5Environments - Fundamentals Webinar Series Week 5
Environments - Fundamentals Webinar Series Week 5
 
Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)Testing Your Automation Code (Vagrant Version)
Testing Your Automation Code (Vagrant Version)
 
Chef basics - write infrastructure as code
Chef basics - write infrastructure as codeChef basics - write infrastructure as code
Chef basics - write infrastructure as code
 
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
Node setup, resource, and recipes - Fundamentals Webinar Series Part 2
 
Cooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with Jitterbug
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlab
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
 
Using Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooksUsing Test Kitchen for testing Chef cookbooks
Using Test Kitchen for testing Chef cookbooks
 
Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2Testing your-automation-code (vagrant version) v0.2
Testing your-automation-code (vagrant version) v0.2
 
Cookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecCookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and Serverrspec
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef Opswork
 
The Berkshelf Way
The Berkshelf WayThe Berkshelf Way
The Berkshelf Way
 
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
Lessons from Etsy: Avoiding Kitchen Nightmares - #ChefConf 2012
 
Ignite Talk on Chef
Ignite Talk on ChefIgnite Talk on Chef
Ignite Talk on Chef
 
Chef
ChefChef
Chef
 
Chef introduction
Chef introductionChef introduction
Chef introduction
 
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and ServerspecTest Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
 

More from Chef

Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed ChefChef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps TourChef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps TourChef
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation WorkshopChef
 
London Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef ComplianceLondon Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef ComplianceChef
 
Learning from Configuration Management
Learning from Configuration Management Learning from Configuration Management
Learning from Configuration Management Chef
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffChef
 
London Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetLondon Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetChef
 
London Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to AuthorshipLondon Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to AuthorshipChef
 
London Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateLondon Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateChef
 
London Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateLondon Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateChef
 
London Community Summit 2016 - Habitat
London Community Summit 2016 -  HabitatLondon Community Summit 2016 -  Habitat
London Community Summit 2016 - HabitatChef
 
Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Chef
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Chef
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Chef
 
Application Automation with Habitat
Application Automation with HabitatApplication Automation with Habitat
Application Automation with HabitatChef
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateChef
 
Nike pop up habitat
Nike pop up   habitatNike pop up   habitat
Nike pop up habitatChef
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshopChef
 
Chef Automate Workflow Demo
Chef Automate Workflow DemoChef Automate Workflow Demo
Chef Automate Workflow DemoChef
 

More from Chef (20)

Habitat Managed Chef
Habitat Managed ChefHabitat Managed Chef
Habitat Managed Chef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
London Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef ComplianceLondon Community Summit 2016 - Adopting Chef Compliance
London Community Summit 2016 - Adopting Chef Compliance
 
Learning from Configuration Management
Learning from Configuration Management Learning from Configuration Management
Learning from Configuration Management
 
London Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef StuffLondon Community Summit 2016 - Fresh New Chef Stuff
London Community Summit 2016 - Fresh New Chef Stuff
 
London Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetLondon Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBet
 
London Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to AuthorshipLondon Community Summit - From Contribution to Authorship
London Community Summit - From Contribution to Authorship
 
London Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateLondon Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef Automate
 
London Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateLondon Community Summit 2016 - Community Update
London Community Summit 2016 - Community Update
 
London Community Summit 2016 - Habitat
London Community Summit 2016 -  HabitatLondon Community Summit 2016 -  Habitat
London Community Summit 2016 - Habitat
 
Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1
 
Application Automation with Habitat
Application Automation with HabitatApplication Automation with Habitat
Application Automation with Habitat
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef Automate
 
Nike pop up habitat
Nike pop up   habitatNike pop up   habitat
Nike pop up habitat
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshop
 
Chef Automate Workflow Demo
Chef Automate Workflow DemoChef Automate Workflow Demo
Chef Automate Workflow Demo
 

Recently uploaded

What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Chef for beginners module 4

  • 1. chef-client Applying Recipes from Cookbooks Slide 1 of 32
  • 2. After completing this module, you should be able to use chef-client to: Locally apply a cookbook's recipe with chef-client. Locally apply multiple cookbooks' recipes with chef- client. Include a recipe from within another recipe. Objectives Slide 2 of 32
  • 3. chef-apply is a great tool for applying resources (-e) and for individual recipes but it doesn't know how to apply a cookbook. chef-apply https://docs.chef.io/ctl_chef_apply.html Slide 3 of 32
  • 4. chef-client is an agent that runs locally on every node that is under management by Chef. When a chef-client is run, it will perform all of the steps that are required to bring the node into the expected state. chef-client https://docs.chef.io/chef_client.html Slide 4 of 32
  • 5. chef-client's default mode attempts to contact a Chef Server and ask it for the recipes to run for the given node. We are overriding that behavior to have it work in a local mode. --local-mode Slide 5 of 32
  • 6. In local mode, we need to provide a list of recipes to apply to the system. This is called a run list. A run list is an ordered collection of recipes to execute. Each recipe in the run list must be addressed with the format recipe[cookbook-name::recipe-name]. -r "recipe[cookbook-name::recipe-name]" Slide 6 of 32
  • 7. When you are referencing the default recipe within a cookbook you may optionally specify only the name of the cookbook. chef-client understands that you mean to apply the default recipe from within that cookbook. -r "recipe[cookbook-name(::default)]" Slide 7 of 32
  • 8. Example Usage Using chef-client to locally apply the setup recipe from the workstation cookbook. $sudochef-client--local-mode–r"recipe[workstation::setup]" Applyingthefollowingrecipeslocally: The'setup'recipefromthe'workstation'cookbook Slide 8 of 32
  • 9. Example Usage Using chef-client to locally apply the server recipe from the apache cookbook. $sudochef-client--local-mode-r"recipe[apache::server]" Applyingthefollowingrecipeslocally: The'server'recipefromthe'apache'cookbook Slide 9 of 32
  • 10. Example Usage Using chef-client to locally apply multiple recipes from multiple cookbooks. $sudochef-client--local-mode -r"recipe[workstation::setup],recipe[apache::server]" Applyingthefollowingrecipeslocally: *The'setup'recipefromthe'workstation'cookbook *The'server'recipefromthe'apache'cookbook Slide 10 of 32
  • 11. Group Exercise: Return Home First $cd~ Slide 11 of 32
  • 12. Group Exercise: Apply the apache::server Recipe Locally $sudochef-client--local-mode-r"recipe[apache::server]" [2015-09-15T14:52:45+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. [2015-09-15T14:52:45+00:00]WARN:Nocookbooksdirectoryfoundatorabovecurrentdirectory. Assuming/home/chef. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["apache::server"] ================================================================================ ErrorResolvingCookbooksforRunList: ================================================================================ Slide 12 of 32
  • 13. Group Exercise: Apply the apache::server Recipe Locally $sudochef-client--local-mode-r"recipe[apache::server]" [2015-09-15T14:52:45+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. [2015-09-15T14:52:45+00:00]WARN:Nocookbooksdirectoryfoundatorabovecurrentdirectory. Assuming/home/chef. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["apache::server"] ================================================================================ ErrorResolvingCookbooksforRunList: ================================================================================ FAIL Slide 13 of 32
  • 14. Group Exercise: Create a cookbooks directory chef-client requires the cookbooks to be in a cookbooks directory located in the user's home directory. $cd~ $mkdircookbooks $mvworkstationcookbooks $mvapachecookbooks Slide 14 of 32
  • 15. Group Exercise: Apply the apache::server Recipe Locally $sudochef-client--local-mode-r"recipe[apache::server]" [2015-09-15T14:54:45+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["apache::server"] SynchronizingCookbooks: -apache CompilingCookbooks... Converging4resources Recipe:apache::server *yum_package[httpd]actioninstall(uptodate) *file[/var/www/html/index.html]actioncreate(uptodate) *service[httpd]actionenable(uptodate) Slide 15 of 32
  • 16. Group Exercise: Apply the workstation::setup Recipe Locally $sudochef-client--local-mode-r"recipe[workstation::setup]" [2015-09-15T15:15:26+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["workstation::setup"] SynchronizingCookbooks: -workstation CompilingCookbooks... Converging6resources Recipe:workstation::setup *yum_package[nano]actioninstall(uptodate) *yum_package[vim]actioninstall(uptodate) *yum_package[emacs]actioninstall(uptodate) Slide 16 of 32
  • 17. Group Exercise: Apply Both Recipes Locally $sudochef-client--local-mode -r"recipe[apache::server],recipe[workstation::setup]" [2015-09-15T15:17:27+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["apache::server","workstation::setup"] SynchronizingCookbooks: -apache -workstation CompilingCookbooks... Runninghandlers: [2015-09-15T15:17:30+00:00]ERROR:Runningexceptionhandlers Runninghandlerscomplete Slide 17 of 32
  • 18. A recipe can include one (or more) recipes located in cookbooks by using the include_recipemethod. When a recipe is included, the resources found in that recipe will be inserted (in the same exact order) at the point where the include_recipekeyword is located. include_recipe https://docs.chef.io/recipes.html#include-recipes Slide 18 of 32
  • 19. Example Usage: Including a Recipe Include the setup recipe from the workstation cookbook in this recipe. include_recipe'workstation::setup' Slide 19 of 32
  • 20. Example Usage: Including a recipe Include the server recipe from the apache cookbook in this recipe. include_recipe'apache::server' Slide 20 of 32
  • 21. Group Exercise: The default recipe includes the setup recipe ~/cookbooks/workstation/recipes/default.rb # #CookbookName::workstation #Recipe::default # #Copyright(c)2015TheAuthors,AllRightsReserved. include_recipe'workstation::setup' Slide 21 of 32
  • 22. Group Exercise: Apply the cookbook's default recipe $sudochef-client--local-mode-r"recipe[workstation]" WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["workstation"] SynchronizingCookbooks: -workstation CompilingCookbooks... Converging0resources Runninghandlers: Runninghandlerscomplete ChefClientfinished,0/0resourcesupdatedin3.300489827seconds Slide 22 of 32
  • 23. Group Exercise: Commit Your Work $cdworkstation $gitadd. $gitcommit-m"Defaultrecipeincludesthesetuprecipe" Slide 23 of 32
  • 24. Update the apache cookbook's default recipe to: Include the server recipe from the apache cookbook Run chef-client and locally apply the run list: recipe[apache] Commit the changes with version control Lab: Update the apache Cookbook Slide 24 of 32
  • 25. Lab: The default recipe includes the apache recipe ~/cookbooks/apache/recipes/default.rb # #CookbookName::apache #Recipe::default # #Copyright(c)2015TheAuthors,AllRightsReserved. include_recipe'apache::server' Slide 25 of 32
  • 26. Lab: Applying the apache default recipe $sudochef-client--local-mode-r"recipe[apache]" [2015-09-15T15:23:18+00:00]WARN:Noconfigfilefoundorspecifiedoncommandline,usingcommandlineoptions. StartingChefClient,version12.3.0 resolvingcookbooksforrunlist:["apache"] SynchronizingCookbooks: -apache CompilingCookbooks... Converging0resources Runninghandlers: Runninghandlerscomplete ChefClientfinished,0/0resourcesupdatedin3.310768509seconds Slide 26 of 32
  • 27. Lab: Commit Your Work $cdapache $gitadd. $gitcommit-m"Defaultrecipeincludestheserverrecipe" Slide 27 of 32
  • 28. Why would you want to apply more than one recipe at a time? Discussion Slide 28 of 32
  • 29. Why would you want to apply more than one recipe at a time? What are the benefits and drawbacks of using include_recipewithin a recipe? Discussion Slide 29 of 32
  • 30. Why would you want to apply more than one recipe at a time? What are the benefits and drawbacks of using include_recipewithin a recipe? Do default values make it easier or harder to learn? Discussion Slide 30 of 32
  • 31. Q&A What questions can we help you answer? chef-client local mode run list include_recipe Slide 31 of 32
  • 32. On to Module 5 Slide 32 of 32