General

Description Command  
Chef Dry Run chef-client -Fmin –why-run  
List Facts ohai  
Bootstrap Chef client knife bootstrap <FQDN/IP>  
Change Chef Run List knife node run_list <add remove> ::
Runlist Status knife status –run-list , knife status “role:webserver” –run-list  

Nodes and Roles

Description Command
List Node Info knife node show
List Nodes per Role knife search node ‘roles:'
Load role from file knife role from file [ [...]]

Data Bags

Load data bag from file knife data bag from file
knife + SSH knife ssh -a ipaddress name:server1 “chef-client” , you can also use patterns: knife ssh -a ipaddress name:www* “uptime”

Debugging

Inheritance

# Invoke chef shell in attribute mode
chef-shell -z
chef > attributes
chef:attributes >

# Query attributes examples
chef:attributes > default["authorized_keys"]
[...]
chef:attributes > node["packages"]
[...]

Editing Files

using a Script resource.

bash "some_commands" do
    user "root"
    cwd "/tmp"
    code <<-EOT
       echo "alias rm='rm -i'" >> /root/.bashrc
    EOT
end

Misc