{"id":31952,"date":"2022-11-27T20:46:29","date_gmt":"2022-11-27T20:46:29","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=31952"},"modified":"2022-12-23T05:45:24","modified_gmt":"2022-12-23T05:45:24","slug":"chef-tutorials-knife-command-line-reference","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/chef-tutorials-knife-command-line-reference\/","title":{"rendered":"Chef Tutorials: knife command line reference"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">knife bootstrap<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife client<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife configure<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife cookbook<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife cookbook site<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife download<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife delete<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife edit<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife list<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife node<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife role<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife show<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife ssh<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife ssl check<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife ssl_fetch<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife status<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife upload<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">knife bootstrap<\/h3>\n\n\n\n<p><strong>Bootstrap a node<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap 12.34.56.789 -P vanilla -x root -r 'recipe[apt],recipe[xfs],recipe[vim]'<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Use an SSH password and sudo whereas &#8211;sudo for execute a bootstrap operation with sudo.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap 192.168.1.1 -x username -P PASSWORD --sudo<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Use an SSH password and sudo whereas &#8211;sudo for execute a bootstrap operation with sudo and &#8211;use-sudo-password for Perform a bootstrap operation with sudo<\/strong><br><strong>Also, specify the name and run list<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap 192.168.1.1 -x username -P PASSWORD --sudo --use-sudo-password --node-name node1 --run-list 'recipe[learn_chef_httpd]'<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: using ssh user and password<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$knife bootstrap ADDRESS --ssh-user USER --ssh-password 'PASSWORD' --sudo --use-sudo-password --node-name node1<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: using SSH identify file, for example ~\/.ssh\/my.pem<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$knife bootstrap ADDRESS --ssh-user USER --sudo --identity-file IDENTITY_FILE --node-name node1<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Use a file that contains a private key<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap 192.168.1.1 -x username -i ~\/.ssh\/id_rsa --sudo<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Fetch and execute an installation script from a URL<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap --bootstrap-install-sh http:\/\/mycustomserver.com\/custom_install_chef_script.sh<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Specify options when using cURL<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap --bootstrap-curl-options \"--proxy http:\/\/myproxy.com:8080\"<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Specify options when using GNU Wget<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap --bootstrap-wget-options \"-e use_proxy=yes -e http:\/\/myproxy.com:8080\"<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Specify a custom installation command sequence<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife bootstrap --bootstrap-install-command \"curl -l http:\/\/mycustomserver.com\/custom_install_chef_script.sh | sudo bash -s --\"<\/code><\/pre>\n\n\n\n<p><strong>Bootstrap a node: Bootstrap a local virtual machine using a forwarded port<\/strong><br><strong>Replace PORT with your SSH forwarded port, for example, 2222, and IDENTITY_FILE with your SSH identify file, for example \/home\/user\/.vagrant\/machines\/default\/virtualbox\/private_key.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$knife bootstrap localhost --ssh-port PORT --ssh-user vagrant --sudo --identity-file IDENTITY_FILE --node-name node1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife cookbook<\/h3>\n\n\n\n<p><strong>Delete a cookbook<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook delete cookbook-name<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook delete cookbook-name 0.8<\/code><\/pre>\n\n\n\n<p><strong>Download a cookbook<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook download cookbook-name<\/code><\/pre>\n\n\n\n<p><strong>View a list of cookbooks<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook list<\/code><\/pre>\n\n\n\n<p><strong>Generate metadata<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook metadata -a<\/code><\/pre>\n\n\n\n<p><strong>Show cookbook data<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook show cookbook-name<\/code><\/pre>\n\n\n\n<p><strong>Test a cookbook<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook test cookbook_name<\/code><\/pre>\n\n\n\n<p><strong>Upload a cookbook<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook upload cookbook_name<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife download<\/h3>\n\n\n\n<p><strong>Use the knife download subcommand to download roles, cookbooks, environments, nodes, and data bags from the Chef server to the current working directory. It can be used to back up data on the Chef server, inspect the state of one or more files, or to extract out-of-process changes users may have made to files on the Chef server, such as if a user made a change that bypassed version source control.<\/strong><br><strong>Download the entire chef-repo<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife download \/<\/code><\/pre>\n\n\n\n<p><strong>Download the \/cookbooks directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife download cookbooks<\/code><\/pre>\n\n\n\n<p><strong>Download the \/environments directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife download environments<\/code><\/pre>\n\n\n\n<p><strong>Download the \/roles directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife download roles<\/code><\/pre>\n\n\n\n<p><strong>Download cookbooks and roles<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$  knife download cookbooks\/apache\\* roles\/webserver.json<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife node<\/h3>\n\n\n\n<p><strong>The knife node subcommand is used to manage the nodes that exist on a Chef server.<\/strong><br><strong>Create a node<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node create node1<\/code><\/pre>\n\n\n\n<p><strong>Delete a node<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node delete node1<\/code><\/pre>\n\n\n\n<p><strong>Edit a node<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node edit node1 -a<\/code><\/pre>\n\n\n\n<p><strong>Delete all the chef nodes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">123456<code>\n$ knife node bulk delete ip*\n$ knife node bulk delete \"^[0-9]{3}$\"\n$ knife node bulk delete .\n  \n  <\/code><\/pre>\n\n\n\n<p><strong>Create a node using a JSON file<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node from file \"PATH_TO_JSON_FILE\"<\/code><\/pre>\n\n\n\n<p><strong>View a list of nodes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node list<\/code><\/pre>\n\n\n\n<p><strong>Add a role<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node run_list add NODE_NAME 'role[ROLE_NAME]'<\/code><\/pre>\n\n\n\n<p><strong>Add roles and recipes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node run_list add NODE_NAME 'recipe[COOKBOOK::RECIPE_NAME],recipe[COOKBOOK::RECIPE_NAME],role[ROLE_NAME]'<\/code><\/pre>\n\n\n\n<p><strong>Add a recipe with a FQDN<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node run_list add NODE_NAME 'recipe[COOKBOOK::RECIPE_NAME]'<\/code><\/pre>\n\n\n\n<p><strong>Add a recipe with a cookbook<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node run_list add NODE_NAME 'COOKBOOK::RECIPE_NAME'<\/code><\/pre>\n\n\n\n<p><strong>Add the default recipe<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife node run_list add NODE_NAME 'COOKBOOK'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife role<\/h3>\n\n\n\n<p><strong>A role is a way to define certain patterns and processes that exist across nodes in an organization as belonging to a single job function. Each role consists of zero (or more) attributes and a run-list. Each node can have zero (or more) roles assigned to it. When a role is run against a node, the configuration details of that node are compared against the attributes of the role, and then the contents of that role\u2019s run-list are applied to the node\u2019s configuration details. When a chef-client runs, it merges its own attributes and run-lists with those contained within each assigned role.<\/strong><br><strong>Create a role<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife role create role1<\/code><\/pre>\n\n\n\n<p><strong>Create a role using JSON data<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife role from file \"path to JSON file\"<\/code><\/pre>\n\n\n\n<p><strong>Delete a role<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife role delete devops<\/code><\/pre>\n\n\n\n<p><strong>Edit a role<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife role edit role1<\/code><\/pre>\n\n\n\n<p><strong>View a list of roles<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife role list -w<\/code><\/pre>\n\n\n\n<p><strong>Use the show argument to view the details of a role.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife role show ROLE_NAME<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife client<\/h3>\n\n\n\n<p><strong>The knife client subcommand is used to manage an API client list and their associated RSA public key-pairs. This allows authentication requests to be made to the Chef server by any entity that uses the Chef server API, such as the chef-client and knife.<\/strong><br><strong>Create an admin client<\/strong><br>To create a chef-client that can access the Chef server API as an administrator\u2014sometimes referred to as an \u201cAPI chef-client\u201d\u2014with the name \u201cexampleorg\u201d and save its private key to a file, enter:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>Create an admin client for Enterprise Chef<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife client create exampleorg -f \"\/etc\/chef\/client.pem\"<\/code><\/pre>\n\n\n\n<p><strong>To delete a client with the name \u201cclient_foo\u201d, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife client delete client_foo<\/code><\/pre>\n\n\n\n<p><strong>To edit a client with the name \u201cexampleorg\u201d, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife client edit exampleorg<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife configure<\/h3>\n\n\n\n<p><strong>Use the knife configure subcommand to create the knife.rb and client.rb files so that they can be distributed to workstations and nodes.<\/strong><br><strong>The following examples show how to use this knife subcommand: Configure knife.rb<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife configure<\/code><\/pre>\n\n\n\n<p><strong>The following examples show how to use this knife subcommand: Configure client.rb<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife configure client '\/directory'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife delete<\/h3>\n\n\n\n<p><strong>Use the knife delete subcommand to delete an object from a Chef server. This subcommand works similar to knife cookbook delete, knife data bag delete, knife environment delete, knife node delete, and knife role delete, but with a single verb (and a single action).<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">knife list<\/h3>\n\n\n\n<p><strong>Use the knife list subcommand to view a list of objects on the Chef server. This subcommand works similar to knife cookbook list, knife data bag list, knife environment list, knife node list, and knife role list, but with a single verb (and a single action).<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">knife ssh<\/h3>\n\n\n\n<p><strong>Use the knife ssh subcommand to invoke SSH commands (in parallel) on a subset of nodes within an organization, based on the results of a search query made to the Chef server.<\/strong><br><strong>To find the uptime of all of web servers running Ubuntu on the Amazon EC2 platform, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssh \"role:web\" \"uptime\" -x ubuntu -a ec2.public_hostname<\/code><\/pre>\n\n\n\n<p><strong>Run the chef-client on all nodes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssh 'name:*' 'sudo chef-client'<\/code><\/pre>\n\n\n\n<p><strong>To force a chef-client run on all of the web servers running Ubuntu on the Amazon EC2 platform, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssh \"role:web\" \"sudo chef-client\" -x ubuntu -a ec2.public_hostname<\/code><\/pre>\n\n\n\n<p><strong>To query for all nodes that have the webserver role and then use SSH to run the command sudo chef-client, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssh \"role:webserver\" \"sudo chef-client\"<\/code><\/pre>\n\n\n\n<p><strong>Upgrade all nodes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssh name:* \"sudo aptitude upgrade -y\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife ssl check<\/h3>\n\n\n\n<p><strong>Use the knife ssl check subcommand to verify the SSL configuration for the Chef server or a location specified by a URL or URI. Invalid certificates will not be used by OpenSSL.<\/strong><br><strong>If the SSL certificate can be verified, the response to<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssl check<\/code><\/pre>\n\n\n\n<p><strong>The SSL certificates that are used by the chef-client may be verified by specifying the path to the client.rb file. Use the &#8211;config option (that is available to any knife command) to specify this path:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssl check --config \/etc\/chef\/client.rb<\/code><\/pre>\n\n\n\n<p><strong>Verify an external server\u2019s SSL certificate<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssl check https:\/\/www.chef.io<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife ssl_fetch<\/h3>\n\n\n\n<p><strong>Use the knife ssl fetch subcommand to copy SSL certificates from an HTTPS server to the trusted_certs_dir directory that is used by knife and the chef-client to store trusted SSL certificates. When these certificates match the hostname of the remote server, running knife ssl fetch is the only step required to verify a remote server that is accessed by either knife or the chef-client.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssl check https:\/\/www.chef.io<\/code><\/pre>\n\n\n\n<p><strong>Fetch the SSL certificates used by Knife from the Chef server<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife ssl fetch<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife status<\/h3>\n\n\n\n<p><strong>Use the knife status subcommand to display a brief summary of the nodes on a Chef server, including the time of the most recent successful chef-client run.<\/strong><br><strong>To include run-lists in the status, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife status --run-list<\/code><\/pre>\n\n\n\n<p><strong>To show the status for nodes on which the chef-client did not run successfully within the past hour, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife status --hide-healthy<\/code><\/pre>\n\n\n\n<p><strong>To show the status of a subset of nodes that are returned by a specific query, enter:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife status \"role:web\" --run-list<\/code><\/pre>\n\n\n\n<p><strong>View status for all nodes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife status<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">knife upload<\/h3>\n\n\n\n<p><strong>Use the knife upload subcommand to upload data to the Chef server from the current working directory in the chef-repo. The following types of data may be uploaded with this subcommand: Cookbooks Data bags Roles stored as JSON data Environments stored as JSON data (Roles and environments stored as Ruby data will not be uploaded.) This subcommand is often used in conjunction with knife diff, which can be used to see exactly what changes will be uploaded, and then knife download, which does the opposite of knife upload.<\/strong><br><strong>Upload the entire chef-repo<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload .<\/code><\/pre>\n\n\n\n<p><strong>Upload the \/cookbooks directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload cookbooks<\/code><\/pre>\n\n\n\n<p><strong>Upload the \/environments directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload environments<\/code><\/pre>\n\n\n\n<p><strong>Upload a single environment<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload environments\/production.json<\/code><\/pre>\n\n\n\n<p><strong>Upload the \/roles directory<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload roles<\/code><\/pre>\n\n\n\n<p><strong>Upload cookbooks and roles<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload cookbooks\/apache\\* roles\/webserver.json<\/code><\/pre>\n\n\n\n<p><strong>Upload Single Cookbook<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook upload [cookbook-name]<\/code><\/pre>\n\n\n\n<p><strong>Upload ALL Cookbooks<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">12<code>$ knife cookbook upload -a\n$ knife cookbook upload --all<\/code><\/pre>\n\n\n\n<p><strong>Freeze Cookbook Version (and Force Upload)<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook upload prod-db --freeze<\/code><\/pre>\n\n\n\n<p><strong>Upload Cookbook with All Dependencies<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">12<code>$ knife cookbook upload thegeekstuff -d\n$ knife cookbook upload thegeekstuff --include-dependencies<\/code><\/pre>\n\n\n\n<p><strong>Increase Number of Concurrent Connections<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife cookbook upload -a --concurrency 20<\/code><\/pre>\n\n\n\n<p><strong>Specify Cookbook Directory Location<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1234<code>$ knife cookbook upload prod-db -o \/root\/chef-repo\/cookbooks\n$ knife cookbook upload prod-db -o \/root\/chef-repo\/cookbooks:\/home\/chef\/cookbooks\n$ knife cookbook upload prod-db --cookbook-path \/root\/chef-repo\/cookbooks\n$ knife cookbook upload prod-db --cookbook-path \/root\/chef-repo\/cookbooks:\/home\/chef\/cookbooks<\/code><\/pre>\n\n\n\n<p><strong>Upload Cookbooks using Upload sub-command<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload cookbooks\/prod-db<\/code><\/pre>\n\n\n\n<p><strong>Upload ALL Cookbooks<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">12<code>$ knife upload cookbooks\n$ knife upload \/cookbooks<\/code><\/pre>\n\n\n\n<p><strong>Upload Roles, Nodes and Environments<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">123456789<code>$ knife upload roles\n$ knife upload nodes\n$ knife upload environments\n$ knife upload \/roles\n$ knife upload \/nodes\n$ knife upload \/environments\n$ knife upload roles\/dba.json\n$ knife upload nodes\/webserver.json\n$ knife upload environment\/oracledb.json<\/code><\/pre>\n\n\n\n<p><strong>Upload the Whole Chef Repo (or) Upload Selective Items<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">123<code>$ knife upload . \n$ knife upload \/\n$ knife upload cookbooks\/prod* nodes\/web*<\/code><\/pre>\n\n\n\n<p><strong>Force Upload even when it\u2019s not Changed Locally<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload cookbooks\/prod-db --freeze<\/code><\/pre>\n\n\n\n<p><strong>Perform Dry Run to Verify what\u2019ll get Uploaded<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1<code>$ knife upload cookbooks --force --dry-run<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>knife bootstrap knife client knife configure knife cookbook knife cookbook site knife download knife delete knife edit knife list knife node knife role knife show knife ssh knife ssl check knife ssl_fetch knife status knife upload knife bootstrap Bootstrap a node 1$ knife bootstrap 12.34.56.789 -P vanilla -x root -r &#8216;recipe[apt],recipe[xfs],recipe[vim]&#8217; Bootstrap a node: Use&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-31952","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/31952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=31952"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/31952\/revisions"}],"predecessor-version":[{"id":31953,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/31952\/revisions\/31953"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=31952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=31952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=31952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}