100 examples of Chef commands for your reference:
- chef-client -v: View Chef client version information.
- chef-solo -v: View Chef Solo version information.
- chef generate cookbook <cookbook_name>: Generates a new Chef cookbook project.
- chef generate recipe <recipe_name>: Generate a new Chef recipe file.
- chef generate attribute <attribute_file_name>: Generates a new Chef attribute file.
- chef generate template <template_file_name>: Generate a new Chef template file.
- chef generate file <file_name>: Generate a new Chef file.
- chef generate lwrp <lwrp_name>: Generate a new Chef LWRP (Lightweight Resource Providers).
- chef generate provider <provider_name>: Generates a new Chef resource provider.
- knife cookbook create <cookbook_name>: Creates a new Chef cookbook.
- knife node show <node_name>: Display detailed information of the specified node.
- knife node list: Lists the names of all known nodes.
- knife cookbook list: List all available cookbooks.
- knife cookbook show <cookbook_name>: Show details for a specific cookbook.
- knife client list: Lists the names of all known clients.
- knife client show <client_name>: Displays detailed information for a specific client.
- knife role list: Lists the names of all roles.
- knife role show <role_name>: Show details for a specific role.
- knife environment list: Lists the names of all environments.
- knife environment show <environment_name>: Show details for a specific environment.
- knife search : Executes a search query on a specified node or on all nodes.
- knife ssh '' '': Use SSH to connect to the queried node and execute the command.
- knife bootstrap <node_name> -x -P : Install the Chef client on a remote node.
- knife cookbook upload <cookbook_name>: upload cookbook to Chef Server.
- knife cookbook delete <cookbook_name>: Delete cookbook from Chef Server.
- knife cookbook download <cookbook_name>: Download cookbook from Chef Server.
- knife node run_list add <node_name> : Add the new recipe to the node's run list.
- knife node run_list remove <node_name> : Remove a specific recipe from the node's run list.
- knife node run_list set <node_name> : Set a specific recipe as the node's run list.
- knife node edit <node_name>: edit the JSON description file of the node.
- knife role create <role_name>: Creates a new Chef role.
- knife role from file : Import the Chef role from a file.
- knife role edit <role_name>: Edit the JSON description file of the Chef role.
- knife role delete <role_name>: Deletes the Chef role from Chef Server.
- knife environment create <environment_name>: Creates a new Chef environment.
- knife environment edit <environment_name>: Edit the JSON description file of the Chef environment.
- knife environment delete <environment_name>: Deletes a Chef environment from Chef Server.
- knife data bag create <bag_name>: Create a new data bag.
- knife data bag list: List the names of all data bags.
- knife data bag show <bag_name>: Display detailed information of the specified packet.
- knife data bag from file : Import a specific data bag from a file.
- knife data bag edit <bag_name>: Edit the JSON description file of the data bag.
- knife data bag delete <bag_name>: Deletes a data bag from Chef Server.
- knife node run_list add <node_name> role[<role_name>]: Adds a specific role to the node's run list.
- knife node run_list remove <node_name> role[<role_name>]: Removes a specific role from the node's run list.
- knife node run_list set <node_name> role[<role_name>]: Set a specific role to the node's run list.
- chef-shell: Start the interactive chef-shell.
- chef-shell -z: Start chef-shell in local mode.
- chef-client -z -o recipe[<recipe_name>]: Run Chef in local mode and only run the specified recipe.
- chef-client -z -n <node_name>: Run Chef in local mode to test the specified node.
- chef gem install <gem_name>: Install the specified Ruby Gem.
- chef gem list: List all installed Ruby Gems.
- chef gem uninstall <gem_name>: Uninstall the specified Ruby Gem.
- chef gem update <gem_name>: Update the specified Ruby Gem.
- chef gem cleanup: Cleans up all installed outdated Ruby gems.
- chef show-policy <policy_group>/<policy_name>: Show details for a specific policy.
- chef install /path/to/policy_archive.tgz -g <policy_group>: Installs the policy archive using the specified policy group.
- chef-push-archive: Upload local policies to Chef Server.
- chef push-client <client_name>: Upload Chef client to Chef Server.
- chef push-job <job_info>: Upload Chef jobs to Chef Server.
- chef push-node <node_name>: Upload the node to Chef Server.
- chef push-policy <policy_file>: Upload the policy file to Chef Server.
- chef push-sandbox <sandbox_path>: Upload Chef sandbox files to Chef Server.
- chef push-user <user_name>: Upload a Chef user to Chef Server.
- chef push : Upload any Chef object to Chef Server.
- chef backup <object_type> <object_name>: Backup Chef objects.
- chef-apply : Run chef-apply with the specified file.
- chef-shell -z : Start chef-shell with the specified file.
- knife ssh 'role:<role_name>' '': Use SSH to connect to all nodes belonging to a specific role and execute commands.
- knife ssh 'chef_environment:<environment_name>' '': Use SSH to connect to all nodes belonging to a specific environment and execute commands.
- knife ssh 'node:<node_name>' '': Use SSH to connect to a specific node and execute commands.
- knife ssh 'name:*' '': Use SSH to connect to all nodes and execute commands.
- knife upload : upload the specified file or directory to Chef Server.
- knife cookbook download -a: Download all cookbooks from Chef Server.
- knife cookbook download -d <cookbook_name>: Download all versions of the specified cookbook from Chef Server.
- knife cookbook download -f <cookbook_name>:: Download a specific version of cookbook from Chef Server.
- knife cookbook site download <cookbook_name>: Download the cookbook from the Cookbook Site.
- knife cookbook site install <cookbook_name>:: Installs a cookbook from the Cookbook Site.
- knife cookbook site show <cookbook_name>: Show details of a specific cookbook on the Cookbook Site.
- knife node edit <node_name>: edit the JSON description file of the node.
- knife search node 'platform_family:debian': Searches for nodes on all Debian systems based on specified criteria.
- knife search environment 'name:_default': Search the default environment according to the specified criteria.
- knife ssh name:server[01-05] '': Use SSH to connect to a set of nodes and execute commands.
- knife ssh “role:web” “apt-get update”: Execute the apt-get update command on all nodes belonging to the web role.
- knife ssh <node_name> “chef-client”: Run chef-client commands remotely.
- knife ssh <node_name> "tail -f /var/log/syslog": Remotely connect to a node and run commands in the background.
- knife ssh <node_name> -i path/to/key “command”: Use the specified SSH key for connection and authentication.
- knife configure -i: Configure Chef tools using an interactive process.
- knife configure -r /path/to/config: Run Chef tools with a specific Chef configuration file.
- chef-client -l debug: Run Chef client in debug mode.
- chef-solo -c solo.rb -j node.json: Run Chef under Chef Solo using the specified configuration file and node JSON file.
- chef-apply -e 'resource "file", "/tmp/index.html" do content "Hello World" end': Run Chef resources directly from the command line.
- chef-vault create <vault_item> <vault_item_id> -J <json_data_file>: Creates a new Chef Vault data item.
- chef-vault item <vault_item> <vault_item_id>: Displays details for a specific Chef Vault data item.
- chef-vault edit <vault_item> <vault_item_id>: Edit a Chef Vault data item.
- chef-vault update <vault_item> <vault_item_id> -J <json_data_file>: Update the content of a Chef Vault data item.
- chef-vault delete <vault_item> <vault_item_id>: Deletes a Chef Vault data item from Chef Server.
- chef verify: Verify that the Chef installation is complete.
- chef env run-tests : Runs all tests in the specified environment.
- chef verify-mode-policy-group <policy_group>: Verify the mode of the specified policy group.