Information Technology Reference
In-Depth Information
EVEN MORE CHOICES: CHEF VERSUS KNIFE
Prior to the Chef Development Kit, developers were required to use many different command-line
tools to perform routine actions. We hope that once the Chef Development Kit reaches its 1.0 re-
lease (which had not yet occurred at the time of this writing), all commands related to cookbook
development will be unified under one umbrella
chef
command-line tool.
Before the Chef Development Kit,
knife
, the primary command-line tool for working with a
Chef Server, could also be used to create a cookbook directory structure for development.
Now, with the advent of the Chef Development Kit, the
chef generate
command is the recom-
mended way to manage a cookbook's directory structure. The
knife
tool won't be going away. It
continues to be the primary command-line tool for interacting with Chef Server in production,
which we'll see later in
Chapter 9
.
However, there is some new functionality in the
chef generate
subcommand that doesn't exist
in
knife
.
chef generate
allows you to customize the recipe and cookbook templates that are
generated. Also,
chef generate
lets you create the directory structure incrementally in a pro-
gressive fashion, adding just the features you need for your cookbook.
knife
generates only one
type of structure, with everything at once, creating many more files than you might need. It
doesn't hurt anything, but many people prefer the incremental approach of
chef generate
.
We'll cover both the
chef
and
knife
approaches to cookbook creation in this chapter.
If you have the Chef Development Kit installed, continue on to the next section,
Your First
Cookbook: Message of the Day (Chef Development Kit)
, to learn how to create a cookbook
book: Message of the Day (Chef Client)
to learn how to create a cookbook using the
knife
utility.
Your First Cookbook: Message of the Day (Chef
Development Kit)
You'll be using a tool called
chef
to generate an initial directory structure for a message of
the day cookbook (motd).
chef
is a new common utility command that debuted with the
Chef Development Kit. On a command line, run the
chef generate cookbook motd
com-
mand to create the cookbook directory scaffolding.
chef generate
will create a main direct-
ory for your cookbook called
motd
as part of the process: