The knife diff subcommand is used 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.
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:
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