Created
June 19, 2012 21:24
-
-
Save jelder/2956628 to your computer and use it in GitHub Desktop.
Backup not-normally-tangibile Chef objects into a Git repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Roles, environments, etc only need to exist in the Chef server, which means | |
# they never hit version control without human intervention (or this script). | |
for data_bag in $(knife data bag list) ; do | |
for item in $(knife data bag show $data_bag) ; do | |
mkdir -p $path data_bags/$data_bag | |
knife data bag show $data_bag $item -Fj > data_bags/$data_bag/$item.json | |
git add data_bags/$data_bag/$item.json | |
done | |
done | |
for role in $(knife role list) ; do | |
knife role show -Fj $role > roles/$role.json | |
git add roles/$role.json | |
done | |
for environment in $(knife environment list) ; do | |
[ "$environment" = "_default" ] && continue | |
knife environment show -Fj $environment > environments/$environment.json | |
git add environments/$environment.json | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment