We learned about the Chef ecosystem in the last chapter and, as we saw, Knife is one of those tools that we'll be using the most while doing development. In this chapter, we'll look at the internals of Knife and we'll also see different plugins, which will make your life a lot easier while managing your infrastructure using Chef.
You're reading from Mastering Chef
Knife is a command-line tool that comes bundled with the Chef installation. Depending upon how Chef was installed, you may find the binary at any particular location on your workstation. Since I have installed Chef using rvm and gem packaging, it is found at ~/.rvm/gems/ruby-2.1.0/gems/chef-11.8.2/bin/knife
.
Depending upon your setup, you may find it at some other location. Whatever the location, ensure that it is in your PATH
variable.
Knife is used for almost every aspect of managing your interactions with chef-server. It helps us manage:
Cookbooks
Environments
Roles
Data bags
Nodes
API clients
Bootstrapping of instances
Searching for nodes
Let's see what the knife
command has to offer to us. Just fire up the terminal and enter the command:
$knife ERROR: You need to pass a sub-command (e.g., knife SUB-COMMAND) Usage: knife sub-command (options) -s, --server-url URL Chef Server URL --chef-zero-port PORT Port to start chef-zero on -k, --key KEY ...
In this chapter, we learned about one of the most widely used components of Chef's ecosystem, called Knife. We looked at the different subcommands of Knife, configuring Knife, and finally some plugins that can be used to extend Knife's functionality.
In the next chapter, we will see why we need to learn Ruby and write efficient infrastructure code using Ruby.