Examples of Chef commands, 100 things you must know

100 examples of Chef commands for your reference:

  1. chef-client -v: View Chef client version information.
  2. chef-solo -v: View Chef Solo version information.
  3. chef generate cookbook <cookbook_name>: Generates a new Chef cookbook project.
  4. chef generate recipe <recipe_name>: Generate a new Chef recipe file.
  5. chef generate attribute <attribute_file_name>: Generates a new Chef attribute file.
  6. chef generate template <template_file_name>: Generate a new Chef template file.
  7. chef generate file <file_name>: Generate a new Chef file.
  8. chef generate lwrp <lwrp_name>: Generate a new Chef LWRP (Lightweight Resource Providers).
  9. chef generate provider <provider_name>: Generates a new Chef resource provider.
  10. knife cookbook create <cookbook_name>: Creates a new Chef cookbook.
  11. knife node show <node_name>: Display detailed information of the specified node.
  12. knife node list: Lists the names of all known nodes.
  13. knife cookbook list: List all available cookbooks.
  14. knife cookbook show <cookbook_name>: Show details for a specific cookbook.
  15. knife client list: Lists the names of all known clients.
  16. knife client show <client_name>: Displays detailed information for a specific client.
  17. knife role list: Lists the names of all roles.
  18. knife role show <role_name>: Show details for a specific role.
  19. knife environment list: Lists the names of all environments.
  20. knife environment show <environment_name>: Show details for a specific environment.
  21. knife search : Executes a search query on a specified node or on all nodes.
  22. knife ssh '' '': Use SSH to connect to the queried node and execute the command.
  23. knife bootstrap <node_name> -x -P : Install the Chef client on a remote node.
  24. knife cookbook upload <cookbook_name>: upload cookbook to Chef Server.
  25. knife cookbook delete <cookbook_name>: Delete cookbook from Chef Server.
  26. knife cookbook download <cookbook_name>: Download cookbook from Chef Server.
  27. knife node run_list add <node_name> : Add the new recipe to the node's run list.
  28. knife node run_list remove <node_name> : Remove a specific recipe from the node's run list.
  29. knife node run_list set <node_name> : Set a specific recipe as the node's run list.
  30. knife node edit <node_name>: edit the JSON description file of the node.
  31. knife role create <role_name>: Creates a new Chef role.
  32. knife role from file : Import the Chef role from a file.
  33. knife role edit <role_name>: Edit the JSON description file of the Chef role.
  34. knife role delete <role_name>: Deletes the Chef role from Chef Server.
  35. knife environment create <environment_name>: Creates a new Chef environment.
  36. knife environment edit <environment_name>: Edit the JSON description file of the Chef environment.
  37. knife environment delete <environment_name>: Deletes a Chef environment from Chef Server.
  38. knife data bag create <bag_name>: Create a new data bag.
  39. knife data bag list: List the names of all data bags.
  40. knife data bag show <bag_name>: Display detailed information of the specified packet.
  41. knife data bag from file : Import a specific data bag from a file.
  42. knife data bag edit <bag_name>: Edit the JSON description file of the data bag.
  43. knife data bag delete <bag_name>: Deletes a data bag from Chef Server.
  44. knife node run_list add <node_name> role[<role_name>]: Adds a specific role to the node's run list.
  45. knife node run_list remove <node_name> role[<role_name>]: Removes a specific role from the node's run list.
  46. knife node run_list set <node_name> role[<role_name>]: Set a specific role to the node's run list.
  47. chef-shell: Start the interactive chef-shell.
  48. chef-shell -z: Start chef-shell in local mode.
  49. chef-client -z -o recipe[<recipe_name>]: Run Chef in local mode and only run the specified recipe.
  50. chef-client -z -n <node_name>: Run Chef in local mode to test the specified node.
  51. chef gem install <gem_name>: Install the specified Ruby Gem.
  52. chef gem list: List all installed Ruby Gems.
  53. chef gem uninstall <gem_name>: Uninstall the specified Ruby Gem.
  54. chef gem update <gem_name>: Update the specified Ruby Gem.
  55. chef gem cleanup: Cleans up all installed outdated Ruby gems.
  56. chef show-policy <policy_group>/<policy_name>: Show details for a specific policy.
  57. chef install /path/to/policy_archive.tgz -g <policy_group>: Installs the policy archive using the specified policy group.
  58. chef-push-archive: Upload local policies to Chef Server.
  59. chef push-client <client_name>: Upload Chef client to Chef Server.
  60. chef push-job <job_info>: Upload Chef jobs to Chef Server.
  61. chef push-node <node_name>: Upload the node to Chef Server.
  62. chef push-policy <policy_file>: Upload the policy file to Chef Server.
  63. chef push-sandbox <sandbox_path>: Upload Chef sandbox files to Chef Server.
  64. chef push-user <user_name>: Upload a Chef user to Chef Server.
  65. chef push : Upload any Chef object to Chef Server.
  66. chef backup <object_type> <object_name>: Backup Chef objects.
  67. chef-apply : Run chef-apply with the specified file.
  68. chef-shell -z : Start chef-shell with the specified file.
  69. knife ssh 'role:<role_name>' '': Use SSH to connect to all nodes belonging to a specific role and execute commands.
  70. knife ssh 'chef_environment:<environment_name>' '': Use SSH to connect to all nodes belonging to a specific environment and execute commands.
  71. knife ssh 'node:<node_name>' '': Use SSH to connect to a specific node and execute commands.
  72. knife ssh 'name:*' '': Use SSH to connect to all nodes and execute commands.
  73. knife upload : upload the specified file or directory to Chef Server.
  74. knife cookbook download -a: Download all cookbooks from Chef Server.
  75. knife cookbook download -d <cookbook_name>: Download all versions of the specified cookbook from Chef Server.
  76. knife cookbook download -f <cookbook_name>:: Download a specific version of cookbook from Chef Server.
  77. knife cookbook site download <cookbook_name>: Download the cookbook from the Cookbook Site.
  78. knife cookbook site install <cookbook_name>:: Installs a cookbook from the Cookbook Site.
  79. knife cookbook site show <cookbook_name>: Show details of a specific cookbook on the Cookbook Site.
  80. knife node edit <node_name>: edit the JSON description file of the node.
  81. knife search node 'platform_family:debian': Searches for nodes on all Debian systems based on specified criteria.
  82. knife search environment 'name:_default': Search the default environment according to the specified criteria.
  83. knife ssh name:server[01-05] '': Use SSH to connect to a set of nodes and execute commands.
  84. knife ssh “role:web” “apt-get update”: Execute the apt-get update command on all nodes belonging to the web role.
  85. knife ssh <node_name> “chef-client”: Run chef-client commands remotely.
  86. knife ssh <node_name> "tail -f /var/log/syslog": Remotely connect to a node and run commands in the background.
  87. knife ssh <node_name> -i path/to/key “command”: Use the specified SSH key for connection and authentication.
  88. knife configure -i: Configure Chef tools using an interactive process.
  89. knife configure -r /path/to/config: Run Chef tools with a specific Chef configuration file.
  90. chef-client -l debug: Run Chef client in debug mode.
  91. chef-solo -c solo.rb -j node.json: Run Chef under Chef Solo using the specified configuration file and node JSON file.
  92. chef-apply -e 'resource "file", "/tmp/index.html" do content "Hello World" end': Run Chef resources directly from the command line.
  93. chef-vault create <vault_item> <vault_item_id> -J <json_data_file>: Creates a new Chef Vault data item.
  94. chef-vault item <vault_item> <vault_item_id>: Displays details for a specific Chef Vault data item.
  95. chef-vault edit <vault_item> <vault_item_id>: Edit a Chef Vault data item.
  96. chef-vault update <vault_item> <vault_item_id> -J <json_data_file>: Update the content of a Chef Vault data item.
  97. chef-vault delete <vault_item> <vault_item_id>: Deletes a Chef Vault data item from Chef Server.
  98. chef verify: Verify that the Chef installation is complete.
  99. chef env run-tests : Runs all tests in the specified environment.
  100. chef verify-mode-policy-group <policy_group>: Verify the mode of the specified policy group.

Guess you like

Origin blog.csdn.net/m0_55877125/article/details/130880241