Hey all,
The knife-essentials commands (knife diff, download, upload, show, list, delete, raw, deps, edit, xargs) have received a major update in master to match knife-essentials 1.3. Some of the bigger changes:
The knife deps
command lets you determine all the dependencies of a given node, role, or cookbook--all the things you would need to upload for it to run. It will run this dependency analysis on your local repository, unless you specify the --remote
option.
By default, it will show all the dependencies in reverse order (i.e. the order in which you would need to load them):
cookbooks/users.json
cookbooks/git.json
cookbooks/github.json
roles/base.json
cookbooks/apache2.json
roles/webserver.json
environments/desert.json
nodes/mynode.json
Passing --tree
will let you see the dependency tree visually:
roles/webserver.json
roles/base.json
cookbooks/github
cookbooks/git
cookbooks/users
cookbooks/apache2
Like all knife-essentials commands, knife deps accepts wildcards and multiple command line parameters.
The output of knife deps is suitable for passing to knife upload
with knife upload `knife deps nodes/*.json`
or knife deps nodes/*.json | xargs knife upload
.
knife edit
is an oft-requested companion to knife show
, knife list
and knife delete
. It works like most of the other nouns, i.e. knife edit myrole.json
is the same as knife role edit myrole
. It also works with wildcards.
knife xargs
is very similar to xargs, except it runs on Chef objects. knife list nodes/* | knife xargs perl -pi -e "s/oldname/newname/g"
will replace all instances of oldname with newname, in all keys and values, for all nodes. It will only upload objects if the program actually changes them.
knife-essentials now has concurrency, giving a 4-8x+ improvement in performance! Commands will make as many parallel requests as they can, up to a maximum defined with the --concurrency
command (defaulting to 10). Ordering of output will be unaffected in some cases (like knife list
) but will be affected in others (like knife upload
, where we print "Updated" as soon as something is updated).
In addition to cookbooks
, data_bags
, environments
, and roles
, knife commands now expose clients
, nodes
, users
(and if you're pointing at Hosted Chef you'll see acls
groups
and containers
). This means you can work with them in any command, including show, edit, list, delete, download, upload, diff. This is a complete list of all data in the Chef server, so knife download /
will now be a full-fidelity backup of your server/organization (see the next section if you have multiple cookbook versions).
Sometimes you want to see ALL your cookbooks, not just the one cookbook you traditionally keep in your repository. If you want to do this, add versioned_cookbooks true
in your knife.rb, and cookbooks will include the version in their name (i.e. cookbooks/apache-1.0.0
, cookbooks/apache-1.0.1
). In this mode, knife download
will download all cookbook versions. This is particularly useful if you are trying to back up your server.
The knife-essentials commands now have a huge set of integration tests, spinning up a chef-zero
server, putting data in it and running knife commands to verify output. This method of testing will spread to other knife commands as time goes by.
Many commands have received new options; knife <command> --help
will show them all. Some of the commands, like --remote and --local
Because of the tests, multi-platform support, output fidelity and robustness are greatly improved.
Enjoy!