knife upload

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.

Syntax

This subcommand has the following syntax:

$ knife upload [PATTERN...] (options)

Options

Note

Review the list of common options available to this (and all) knife subcommands and plugins.

This subcommand has the following options:

--force
Use --force to upload roles, cookbooks, etc. even if the file in the directory is identical (by default, no POST or PUT is performed unless an actual change would be made).
-n, --dry-run
Take no action and only print out results.
--purge
Use --purge to delete roles, cookbooks, etc. from the Chef server if their corresponding files do not exist in the chef-repo. By default, such objects are left alone and NOT purged.
--recurse
Use --no-recurse to disable uploading a directory recursively. Default: --recurse.

Note

See knife.rb for more information about how to add certain knife options as settings in the knife.rb file.

Examples

Browse to the top level of the chef-repo and enter:

$ knife upload .

or from anywhere in the chef-repo, enter:

$ knife upload /

to upload all cookbooks and data bags, plus all roles and enviroments that are stored as JSON data. (Roles and environments stored as Ruby data will not be uploaded.)

Browse to the top level of the chef-repo and enter:

$ knife upload cookbooks

or from anywhere in the chef-repo, enter:

$ knife upload /cookbooks

Browse to the top level of the chef-repo and enter:

$ knife upload environments

or from anywhere in the chef-repo, enter:

$ knife upload /environments

to upload all enviroments that are stored as JSON data. (Environments stored as Ruby data will not be uploaded.)

Browse to the top level of the chef-repo and enter:

$ knife upload environments/production.json

or from the environments/ directory, enter:

$ knife upload production.json

Browse to the top level of the chef-repo and enter:

$ knife upload roles

or from anywhere in the chef-repo, enter:

$ knife upload /roles

to upload all roles that are stored as JSON data. (Roles stored as Ruby data will not be uploaded.)

Browse to the top level of the chef-repo and enter:

$ knife upload cookbooks/apache\* roles/webserver.json