Chef – The Local Cookbook Development Badge
The Chef Local Cookbook Development Badge course is designed to prepare you for the Chef Local Cookbook Development Badge exams. By passing the exams and obtaining this badge, you will demonstrate your ability to properly develop a basic Chef cookbook.
Earning this Chef Badge shows you have the skills to develop a basic cookbook in Chef.It shows you have the ability to take a process that exists and automate it, demonstrating your understanding of creating a cookbook. You will have shown your ability to validate the functionality of the cookbook before it is run on production or 'live' infrastructure.
If you obtain the badge you will be on your way to obtaining Chef certification.
In this lesson, we’ll talk about why anyone would want the Local Cookbook Development Badge, and what we will cover in this course.
About the Exam
In this lesson, we’ll cover details about the exam, where it fits into the overall scheme of Chef Certifications, and also mention some tips along the way for preparing to take the exam. There are two versions of the exam: one on a Linux platform, and the other on a Windows platform. The Windows platform used at the time of this course's creation is Windows Server 2012 R2, but it will be updated to use Windows Server 2019. The exam has a combination of multiple choice questions and performance-based screnarios. The exam platform will have Chef DK 2.4.17 installed, and includes pre-installed editors such as Vim and Atom. Exam candidates who fail the exam must wait one week before retrying. Exam vouchers are available for purchase at https://training.chef.io/local-cookbook-development-badge.
Chef Badges Overview
In this lesson, we'll discuss the scope of topics that the Local Cookbook Development Badge exam covers. We'll explore the Chef certification website, where exam purchasing and scheduling is available. For more information about the Chef Badges, visit https://training.chef.io/certification The page that covers the Chef Local Cookbook Development Badge is https://training.chef.io/local-cookbook-development-badge
About the Training Architect
Introducing the course author: Kevin James I hope you like this course and gain value from it. If you have questions relating to the course, then feel free to contact me in the Community on the Linux Academy website or via our slack channel.
Setup Your Environment
Intro to ChefDK
This lesson discusses ChefDK and its components. We also discuss what Chef provides, and what the community does.
Local Chef Workstation Setup: ChefDK
This lesson shows how to install the ChefDK software. We obtain it from the URL here: https://downloads.chef.io/chefdk/stable/2.4.17 The commands used to install are:
wget https://packages.chef.io/files/stable/chefdk/2.4.17/el/7/chefdk-2.4.17-1.el7.x86_64.rpm sudo rpm -ivh chefdk-2.4.17-1.el7.x86_64.rpm echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profile source ~/.bash_profile
Set up Prerequisites on a Linux Server for Local Testing
In this lesson we set up Git and Docker, since they are prerequisites for the tasks we will perform in later lessons. We also install the required gem to use with Docker.
Cookbook Authoring and Setup Theory
Repository Structure: Monolithic vs. Single Cookbook
In this lesson we discuss the following:The pros and cons of a single repository per cookbook The pros and cons of an application repository How the Chef workflow supports monolithic vs. single cookbooks How to create a repository/workspace on the workstation
Versioning of Cookbooks
In this lesson we discuss the following:Why cookbooks should be versioned The recommended methods of maintaining versions (e.g. knife spork) How to avoid overwriting cookbooks Where to define a cookbook version Semantic versioning Freezing cookbooks Re-uploading and freezing cookbooks
Structuring Cookbook Content
In this lesson we discuss the following:Modular content/reusability Best practices around cookbooks that map 1:1 to a piece of software or functionality, as opposed to monolithic cookbooks How to use common, core resources
How Metadata Is Used
In this lesson we discuss the following:How to manage dependencies Cookbook dependency version syntax What information to include in a cookbook, like author, license, etc. Metadata settings What suggests in metadata means What issues_url in metadata means
Wrapper Cookbook Methods
In this lesson we discuss the following:How to consume other cookbooks in code via wrapper cookbooks How to change cookbook behavior via wrapper cookbooks Attribute value precedence How to use the include_recipe directive What happens if the same recipe is included multiple times How to use the depends directive
Using Community Cookbooks
In this lesson we discuss the following:How to use a public and private Supermarket How to use community cookbooks How to wrap community cookbooks How to fork community cookbooks How to use Berkshelf to download cookbooks How to configure a Berksfile How to use a Berksfile to manage a community cookbook and a local cookbook with the same name
Using Chef Resources vs. Arbitrary Commands
In this lesson we discuss the following:How to
shell out to run commands
How to use the
When and when not to use the
How to ensure idempotence
The `chef` Command
In this lesson we will learn the following:What the
chef command does
chef generate can create
How to customize content using generators
The recommended way to create a template
How to add the same boilerplate text to every recipe created by a team
chef gem command and what it isNote: Code used in this lab can be found on the Linux Academy Github at https://github.com/linuxacademy/content-chef-localcookbookdev/tree/master/Lessons/Chef_Command
In this lesson we discover the following:What Foodcritic is Why developers should lint their code Foodcritic errors and how to fix them Community coding rules and custom rules Foodcritic commands Foodcritic rules How to exclude Foodcritic rules
In this lesson we learn about the following:Using
berks to work with upstream dependencies
Working with GitHub and Supermarket
Dealing with dependent cookbooks
Locking cookbook versions
Managing dependencies using
In this lesson we will cover the following topics:How to use RuboCop to check Ruby styles RuboCop vs. Foodcritic RuboCop configuration and commands Auto correction How to be selective about which rules get run
In this lesson we will discuss the following:Writing tests to verify intent
How to focus tests on critical outcomes
How to test each resource component vs how to test for desired outcomes
kitchen command to test and to converge a cookbook onto a Docker instance
In this lesson we discuss and show examples for the following:Test Kitchen provider and platform support
How to use
.kitchen.yml to set up complex testing matrices
How to test a cookbook on multiple deployment scenarios
How to configure drivers
In this lesson we cover the following:The available provisioners
How to configure provisioners
When to use
chef-solo vs. Chef
How to use the shell provisioner
In this lesson we cover the following:What a suite is How to use suites to test different recipes in different environments Testing a directory for InSpec How to configure suites
In this lesson we will cover the following: How to specify platforms. Common platforms. How to locate base images. Common images and custom images.
In this lesson we discuss the following:The basic Test Kitchen workflow
When tests get run
How to install bussers
kitchen init does
Directory Structure of a Cookbook
In this lesson we discuss the following:What the components of a cookbook are
What siblings of cookbooks in a repository are
Why there is a
default subdirectory under
Where tests are stored
Attributes and How They Work
In this lesson we discuss the following:What attributes are
Attributes as a nested hash
How attributes are defined
How attributes are named
How attributes are referenced
Attribute precedence levels
What Ohai is
platform attribute is
How to use the
platform attribute in recipes
Files and Templates
In this lesson we discuss the following:How to instantiate files on nodes
The difference between
How two teams can manage the same file
How to write templates
What partial templates are
Common file-related resource actions and properties
In this lesson we discuss the following:What custom resources are How to consume resources specified in another cookbook Naming conventions How to test custom resourcesNote: The code refenced in this lesson can be found here on GitHub.
In this lesson we discuss the following:What libraries are and when to use them Where libraries are storedNote: The code refenced in this lesson can be found here on GitHub.
Available Testing Frameworks
In this lesson we discuss the following:How to test common resources with InSpec InSpec syntax How to write InSpec tests How to run InSpec tests Where InSpec tests are storedNote: The code refenced in this lesson can be found here on GitHub.
In this lesson we discuss the following:What ChefSpec is The ChefSpec value proposition What happens when you run ChefSpec ChefSpec syntax How to write ChefSpec tests How to run ChefSpec tests Where ChefSpec tests are storedNote: The code refenced in this lesson can be found here on GitHub.
Generic Testing Topics
In this lesson we discuss the following:The test-driven development (TDD) workflow Where tests are stored How tests are organized in a cookbook Naming conventions - how Test Kitchen finds tests Tools to test code "at rest" Integration testing tools Tools to run code and test the output When to use ChefSpec in the workflow When to use Test Kitchen in the workflow Testing intent Functional vs unit testing
Reading Test Kitchen Output
In this lesson we focus on two things:Test Kitchen phases Associated outputNote: The code refenced in this lesson can be found here on GitHub
Compile vs. Converge
In this lesson we discuss the following:What happens during the compile phase of a
chef client run?
What happens during the execution phase of a
chef client run?
When is pure Ruby code executed?
When is Chef code executed?Note: The code refenced in this lesson can be found here on GitHub.
Search and Data Bags
In this lesson we discuss the following:What data bags are
Where data bags are stored
When to use data bags
How to use data bags
How to create a data bag
How to update a data bag
How to search data bags
The difference between data bags and attributes
knife commands to use to CRUD (Create, Read, Update, and Delete) data bagsNote: The code refenced in this lesson can be found here on GitHub.
In this lesson we discuss the following:What data is indexed and searchable Why you would search in a recipe Search criteria syntax How to invoke a search from the command line How to invoke a search from within a recipeNote: The code refenced in this lesson can be found here on GitHub.
How to Prepare for the Chef Badge Exams
The Local Cookbook Development assessment is a blend of multiple choice questions and performance scenarios where you will work with Chef to meet specific objectives. You are given 90 minutes to complete the exam To prepare for the exam I encourage you to do the following: Deploy your own Chef DK server and practice each of the elements shown in this course. Read over the Local Cookbook Development Badge Topics document from Chef. Utilize the search functionality of docs.chef.io to ensure that you can quickly look up information that you don't know. Practice building environments in kitchen. Create some of your own cookbooks based on configuration tasks that you've done in the past. Convert configuration scripts you may have written into recipes to get practice creating recipes and using resources. Go through this course's Hands-On Labs until you feel comfortable carrying out each task without watching the solution videos. Have a look at the code used in the course. It can be found here on GitHub.
What are the next steps, now that you have completed the course? If you've successfully taken and passed the Chef Local Cookbook Development Badge exam then congratulations! If you haven't take the exam yet, you should feel confident going into the exam if you've diligently followed along with the examples in this course, taken the quizzes and practice exams, and gone through the live environments. After you have passed the exam it is time to move onto a new challenge. A great next step would be to start preparing for the other badges available from Chef. If you havent gotten the Basic Chef Fluency Badge yet then you could always round things out by adding that one. You can use the search option available on the Linux Academy Website and make use of those courses as well. There is the Extending Chef Badge course which will help you extend your chef knowledge. I hope that you enjoyed this course and felt that it prepared you well for the exam. If there were any parts of the course that you particularly liked or disliked please go back to those pieces of content (videos, live environments, quiz questions, etc.) and leave a rating so that I can continue to improve this course. Thank you for helping us make better content and trusting us with your valuable time.
Take this course and learn a new skill today.
Transform your learning with our all access plan.Start 7-Day Free Trial