The knife download subcommand is used 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. This subcommand is often used in conjunction with knife diff, which can be used to see exactly what changes will be downloaded, and then knife upload, which does the opposite of knife download.
Note
Review the list of common options available to this (and all) Knife subcommands and plugins.
This subcommand has the following options:
The following examples show how to use this Knife subcommand:
Download the entire chef-repo
To download the entire chef-repo from the Chef server, browse to the top level of the chef-repo and enter:
$ knife download /
Download the /cookbooks directory
To download the cookbooks/ directory from the Chef server, browse to the top level of the chef-repo and enter:
$ knife download cookbooks
or from anywhere in the chef-repo, enter:
$ knife download /cookbooks
Download the /environments directory
To download the environments/ directory from the Chef server, browse to the top level of the chef-repo and enter:
$ knife download environments
or from anywhere in the chef-repo, enter:
$ knife download /environments
Download an environment
To download an environment named “production” from the Chef server, browse to the top level of the chef-repo and enter:
$ knife download environments/production.json
or from the environments/ directory, enter:
$ knife download production.json
Download the /roles directory
To download the roles/ directory from the Chef server, browse to the top level of the chef-repo and enter:
$ knife download roles
or from anywhere in the chef-repo, enter:
$ knife download /roles
Download cookbooks and roles
To download all cookbooks that start with “apache” and belong to the “webserver” role, browse to the top level of the chef-repo and enter:
$ knife download cookbooks/apache\* roles/webserver.json