A set of export plugins for Chef's knife
.
Just copy one or more of the files from the knife/
subdirectory of this repo
to your knife plugin directory. That's either in your home or in your chef-repo:
cp knife/* ~/.chef/plugins/knife
cp knife/* <chef-repo>/.chef/plugins/knife
Running knife
with no arguments should now show three new options:
knife data bag export all (options)
knife node export all (options)
knife role export all (options)
Exports all the data bags with their content in JSON format and writes them to the data_bags
directory of your chef-repo.
To help keep the SCM diffs manageable, the JSON object is sorted in a reasonable, stable way. In particular:
- some well-known data bags are recognized, and their content is sorted in a way that makes sense for humans;
- all other hashes are sorted alphabetically;
- arrays and plain strings are passed through unmodified
Exports all the nodes in JSON format and writes them to the nodes
directory of your chef-repo.
To help keep the SCM diffs manageable, the JSON object is sorted in a reasonable, stable way. In particular:
- only normal attributes are sorted (for now);
- the
log
attribute (used by nuclearrooster's update handler) is removed; - all other hashes are sorted alphabetically;
- arrays and plain strings are passed through unmodified
Exports all the roles in JSON format and writes them to the nodes
directory of your chef-repo.
To help keep the SCM diffs manageable, the JSON object is sorted in a reasonable, stable way. In particular:
- normal and override attributes are sorted;
- all other hashes are sorted alphabetically;
- arrays and plain strings are passed through unmodified
You can do whatever you want with this code :)