Chef

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/OptionExampleDescription
chef –versionchef --versionDisplay the version of Chef installed
chef generate repochef generate repo my-repoGenerate a new Chef repository
chef generate cookbookchef generate cookbook my-cookbookGenerate a new Chef cookbook

Knife Commands #

Command/OptionExampleDescription
knife configureknife configureCreate the knife configuration file (knife.rb)
knife ssl fetchknife ssl fetchFetch SSL certificates for the Chef server
knife client listknife client listList all registered clients
knife user listknife user listList all users
knife cookbook createknife cookbook create my-cookbookCreate a new cookbook
knife cookbook uploadknife cookbook upload my-cookbookUpload a cookbook to the Chef server
knife node listknife node listList all nodes
knife role listknife role listList all roles

Chef Client #

Command/OptionExampleDescription
chef-clientchef-clientRun the Chef client on the node
chef-client -ochef-client -o 'recipe[cookbook::recipe]'Run a specific recipe

Chef Server Management #

Command/OptionExampleDescription
chef-server-ctl reconfigurechef-server-ctl reconfigureReconfigure the Chef server
chef-server-ctl statuschef-server-ctl statusCheck the status of the Chef server
chef-server-ctl user-createchef-server-ctl user-create my-userCreate a new user on the Chef server
chef-server-ctl org-createchef-server-ctl org-create my-orgCreate a new organization on the Chef server

Berkshelf #

Command/OptionExampleDescription
berks initberks initInitialize a Berkshelf repository
berks installberks installInstall the cookbooks specified in the Berksfile
berks uploadberks uploadUpload the cookbooks to the Chef server
berks listberks listList the installed cookbooks

Test Kitchen #

Command/OptionExampleDescription
kitchen initkitchen initInitialize a Test Kitchen configuration
kitchen listkitchen listList all instances
kitchen convergekitchen convergeApply the Chef run on the instance
kitchen verifykitchen verifyRun tests on the instance
kitchen destroykitchen destroyDestroy the Test Kitchen instance

InSpec #

Command/OptionExampleDescription
inspec init profileinspec init profile my-profileInitialize a new InSpec profile
inspec execinspec exec my-profileRun tests in the specified profile
inspec checkinspec check my-profileCheck the profile for errors
inspec archiveinspec archive my-profileCreate 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.

Chef

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.