knife diff subcommand to compare the differences between files and directories on the Chef server and in the chef-repo. For example, to compare files on the Chef server prior to an uploading or downloading files using the
knife download and
knife upload subcommands, or to ensure that certain files in multiple production environments are the same. This subcommand is similar to the
git diff command that can be used to diff what is in the chef-repo with what is synced to a git repository.
This subcommand has the following syntax:
$ knife diff [PATTERN...] (options)
Review the list of common options available to this (and all) knife subcommands and plugins.
This subcommand has the following options:
A), deleted (
D), modified (
M), and/or have had their type changed (
T). Any combination of filter characters may be used, including no filter characters. Use
*to select all paths if a file matches other criteria in the comparison. Default value:
--no-recurseto disable listing a directory recursively. Default:
staticfor just roles, environments, cookbooks, and data bags. By default,
hosted_everythingare dynamically selected depending on the server type. Default:
See knife.rb for more information about how to add certain knife options as settings in the knife.rb file.
The following examples show how to use this knife subcommand:
Compare files that contain JSON data
To compare the
base.json role to a
webserver.json role, enter:
$ knife diff roles/base.json roles/webserver.json
Compare the chef-repo and the server
To compare the differences between the local chef-repo and the files that are on the Chef server, enter:
$ knife diff
Compare, then return results
To diff a node named
node-lb and then only return files that have been added, deleted, modified, or changed, enter:
$ knife diff --name-status node-lb
to return something like:
node-lb/recipes/eip.rb node-lb/recipes/heartbeat-int.rb node-lb/templates/default/corpsite.conf.erb node-lb/files/default/wildcard.node.com.crt node-lb/files/default/wildcard.node.com.crt-2009 node-lb/files/default/wildcard.node.com.key node-lb/.gitignore node-lb/Rakefile
© Chef Software, Inc.
Licensed under the Creative Commons Attribution 3.0 Unported License.
The Chef™ Mark and Chef Logo are either registered trademarks/service marks or trademarks/servicemarks of Chef, in the United States and other countries and are used with Chef Inc's permission.
We are not affiliated with, endorsed or sponsored by Chef Inc.