Chef Cheatsheet
#
Chef is an open-source infrastructure automation tool that simplifies the process of managing complex infrastructure by converting infrastructure into code. Chef automates how infrastructure is configured, deployed, and managed across your network, making it easier to manage and scale environments.
Chef Workstation Setup
#
Command/Option | Example | Description |
---|
chef –version | chef --version | Display the version of Chef installed |
chef generate repo | chef generate repo my-repo | Generate a new Chef repository |
chef generate cookbook | chef generate cookbook my-cookbook | Generate a new Chef cookbook |
Knife Commands
#
Command/Option | Example | Description |
---|
knife configure | knife configure | Create the knife configuration file (knife.rb) |
knife ssl fetch | knife ssl fetch | Fetch SSL certificates for the Chef server |
knife client list | knife client list | List all registered clients |
knife user list | knife user list | List all users |
knife cookbook create | knife cookbook create my-cookbook | Create a new cookbook |
knife cookbook upload | knife cookbook upload my-cookbook | Upload a cookbook to the Chef server |
knife node list | knife node list | List all nodes |
knife role list | knife role list | List all roles |
Chef Client
#
Command/Option | Example | Description |
---|
chef-client | chef-client | Run the Chef client on the node |
chef-client -o | chef-client -o 'recipe[cookbook::recipe]' | Run a specific recipe |
Chef Server Management
#
Command/Option | Example | Description |
---|
chef-server-ctl reconfigure | chef-server-ctl reconfigure | Reconfigure the Chef server |
chef-server-ctl status | chef-server-ctl status | Check the status of the Chef server |
chef-server-ctl user-create | chef-server-ctl user-create my-user | Create a new user on the Chef server |
chef-server-ctl org-create | chef-server-ctl org-create my-org | Create a new organization on the Chef server |
Berkshelf
#
Command/Option | Example | Description |
---|
berks init | berks init | Initialize a Berkshelf repository |
berks install | berks install | Install the cookbooks specified in the Berksfile |
berks upload | berks upload | Upload the cookbooks to the Chef server |
berks list | berks list | List the installed cookbooks |
Test Kitchen
#
Command/Option | Example | Description |
---|
kitchen init | kitchen init | Initialize a Test Kitchen configuration |
kitchen list | kitchen list | List all instances |
kitchen converge | kitchen converge | Apply the Chef run on the instance |
kitchen verify | kitchen verify | Run tests on the instance |
kitchen destroy | kitchen destroy | Destroy the Test Kitchen instance |
InSpec
#
Command/Option | Example | Description |
---|
inspec init profile | inspec init profile my-profile | Initialize a new InSpec profile |
inspec exec | inspec exec my-profile | Run tests in the specified profile |
inspec check | inspec check my-profile | Check the profile for errors |
inspec archive | inspec archive my-profile | Create an archive of the profile |
This cheatsheet covers the most commonly used Chef commands and options, helping you to manage workstations, servers, cookbooks, clients, and tests effectively.