Creating a Cookbook

To keep our example straightforward, we’ll create a Chef Infra cookbook that automates the installation and management of the Git distributed version control system. While a robust Git cookbook already exists on the Chef Supermarket, building our own simple version will help demonstrate all the features of Test Kitchen within a typical workflow.

First of all, let’s generate a cookbook skeleton.

$ chef generate cookbook git_cookbook
Generating cookbook git_cookbook
- Ensuring correct cookbook content
- Committing cookbook files to git

Your cookbook is ready. Type `cd git_cookbook` to enter it.

There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local --help` to see a full list of local testing commands.

Why not start by writing an InSpec test? Tests for the default recipe are stored at:

test/integration/default/default_test.rb

If you'd prefer to dive right in, the default recipe can be found at:

recipes/default.rb

Congratulations. You’ve authored a Chef Infra cookbook.

Make sure you’ve changed into the new cookbook directory via cd git_cookbook. Next we’ll talk about what just happened and how Test Kitchen configuration works.