SlideShare a Scribd company logo
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

Chef training Day4
Chef training Day4Chef training Day4
Chef training Day4
Andriy Samilyak
 
Chef training Day5
Chef training Day5Chef training Day5
Chef training Day5
Andriy Samilyak
 
Chef training - Day3
Chef training - Day3Chef training - Day3
Chef training - Day3
Andriy Samilyak
 
Chef training - Day2
Chef training - Day2Chef training - Day2
Chef training - Day2
Andriy Samilyak
 
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
Mandi Walls
 
Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014Cookbook Reusability @ Chef Community summit 2014
Cookbook Reusability @ Chef Community summit 2014
Sean OMeara
 
IT Automation with Chef
IT Automation with ChefIT Automation with Chef
IT Automation with Chef
Anuchit Chalothorn
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
Antons Kranga
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
Sri 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 Gulp
Anderson Aguiar
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.js
Bo-Yi Wu
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
Cooking Perl with Chef
Cooking Perl with ChefCooking Perl with Chef
Cooking Perl with Chef
David Golden
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazel
Natan Silnitsky
 
Welcome to Jenkins
Welcome to JenkinsWelcome to Jenkins
Welcome to Jenkins
Somkiat Puisungnoen
 
第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 plugin
Anthony 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 jenkins
Huang Bruce
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
Andrii 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 6
Chef
 
How to Write Chef Cookbook
How to Write Chef CookbookHow to Write Chef Cookbook
How to Write Chef Cookbook
devopsjourney
 
Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4Compliance Automation with Inspec Part 4
Compliance Automation with Inspec Part 4
Chef
 
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 code
stevaaa
 
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
Chef
 
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
David Golden
 
Azure handsonlab
Azure handsonlabAzure handsonlab
Azure handsonlab
Chef
 
Introduction to Chef
Introduction to ChefIntroduction to Chef
Introduction to Chef
Knoldus 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 cookbooks
Timur 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.2
Sylvain Tissot
 
Cookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and ServerrspecCookbook testing with KitcenCI and Serverrspec
Cookbook testing with KitcenCI and Serverrspec
Daniel Paulus
 
Kickstarter - Chef Opswork
Kickstarter - Chef OpsworkKickstarter - Chef Opswork
Kickstarter - Chef Opswork
Hamza 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 2012
Patrick McDonnell
 
Ignite Talk on Chef
Ignite Talk on ChefIgnite Talk on Chef
Ignite Talk on Chef
Bob Nowadly
 
Chef
ChefChef
Chef introduction
Chef introductionChef introduction
Chef introduction
FENG Zhichao
 
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
Yury 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 Chef
Chef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
Chef
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
Chef
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
Chef
 
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
Chef
 
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 Stuff
Chef
 
London Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBetLondon Community Summit - Chef at SkyBet
London Community Summit - Chef at SkyBet
Chef
 
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
Chef
 
London Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef AutomateLondon Community Summit 2016 - Chef Automate
London Community Summit 2016 - Chef Automate
Chef
 
London Community Summit 2016 - Community Update
London Community Summit 2016 - Community UpdateLondon Community Summit 2016 - Community Update
London Community Summit 2016 - Community Update
Chef
 
London Community Summit 2016 - Habitat
London Community Summit 2016 -  HabitatLondon Community Summit 2016 -  Habitat
London Community Summit 2016 - Habitat
Chef
 
Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3Compliance Automation with Inspec Part 3
Compliance Automation with Inspec Part 3
Chef
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
Chef
 
Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1Compliance Automation with Inspec Part 1
Compliance Automation with Inspec Part 1
Chef
 
Application Automation with Habitat
Application Automation with HabitatApplication Automation with Habitat
Application Automation with Habitat
Chef
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef Automate
Chef
 
Nike pop up habitat
Nike pop up   habitatNike pop up   habitat
Nike pop up habitat
Chef
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshop
Chef
 
Chef Automate Workflow Demo
Chef Automate Workflow DemoChef Automate Workflow Demo
Chef Automate Workflow Demo
Chef
 

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

APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 

Recently uploaded (20)

APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 

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