Skip to content

Chef Commands

Useful commands for working with Chef on a workstation or on a node.

Local Checks

chef-client -v
chef-solo -v
knife --version

Cookbook and Repository Workflow

wget http://github.com/chef-cookbooks/chef-repo/tarball/master -O - | tar xzf - --strip-components=1
knife supermarket download mysql

Running Chef

chef-solo -c solo.rb -j web.json
chef-client

Common Patterns

execute 'compile' do
  cwd '/usr/local/src/node-v#{version}'
  command 'make install'
  creates '/usr/local/src/node-v#{version}/node'
end
remote_file '/usr/local/src/hi.tar.gz' do
  source 'http://example.com/hi.tar.gz'
  mode 0644
  action :create_if_missing
end

Practical Notes

  • Use knife for interaction with Chef server and cookbooks.
  • Use chef-client on managed nodes in the normal converged workflow.
  • Use chef-solo only when you intentionally want a standalone setup.