Let's say you have a standard Chef repository with directories as follows:
cookbooks
data_bags
environments
roles
Is there way to upload it all in one go? Otherwise you have to do this:
knife cookbook upload -a
knife data bag from file data_bags/*.json
knife environment from file environments/*.rb
knife role from file roles/*.json
Perhaps there are third-party tools to do this kind of thing?
You could write a simple bash script to do that like:
then call it using ./script.sh, this will do everything automatically.
Make sure you are using ruby 1.9, then install knife-essentials
Then add the following to ~/.chef/knife.rb
Then you can download/upload your entire server, or just parts of it. Downloading will put a lot of .json files in your chef-repo, good for backups I found.
Also note that if you have roles stored as ruby files (e.g:
roles/*.rb
), you will need to convert them to json. Then you can re-download them from chef server as json. For example:knife role from file roles/*.rb
knife download roles/
This method is also used to upgrade from chef server 10 to 11.
I wrote a small knife plugin called sync-all described below that accomplishes this as well:
https://github.com/cdoughty77/knife-sync-all
Currently the docs say you should simply
knife upload /
. There are other possibilities in the docs.From the chef repository.
If you execute
knife upload .
it uploads everything.