Skip to content

Instantly share code, notes, and snippets.

@octplane
Created April 19, 2011 15:54
Show Gist options
  • Save octplane/928575 to your computer and use it in GitHub Desktop.
Save octplane/928575 to your computer and use it in GitHub Desktop.
Quickly upload changes to a chef server (0.8)
#!/bin/sh
diff -x .gitignore -x .DS_Store -x metadata.json -x "README" -qr cookbooks/ /srv/chef/cookbooks/ | grep -v "Only in
/srv/chef/cookbooks/" | sed -e "s/.*cookbooks\/[ :]*//;s/\/.*//;s/:.*//" | sort | uniq | xargs knife cookbook upload
for a in `diff -x .gitignore -x metadata.json -x "README" -qr cookbooks/ /srv/chef/cookbooks/ | grep "Only in /srv/
chef/cookbooks/" | sed -e "s/.*cookbooks\/[ :]*//;s/\/.*//;s/:.*//" | sort | uniq`; do
echo "y" | knife cookbook delete $a
done
@octplane
Copy link
Author

For Chef 0.8
Run this from an admin node, inside the root of your chef cookbook repository.

Assumes:

  • your chef stores its data in /src/chef/cookbooks (have a look before running it)

Advantages:

  • way faster than any upload method.
  • rather safe (if you have a copy of your cookbooks in a SCM)

Issues:

  • Only process ./cookbooks
  • Can sometimes delete non removed cookbooks. Run again to fix !
  • Does not process roles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment