Last active
February 15, 2016 18:52
-
-
Save rmoriz/c3e7d8fd5061480b680b to your computer and use it in GitHub Desktop.
Copy chef data bags
This file contains 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 | |
function copy_data_bag() { | |
data_bag=$1 | |
data_bag_item=$2 | |
new_data_bag_item=$3 | |
tmp_file_old=$(mktemp) | |
tmp_file_new=$(mktemp) | |
chef exec knife data bag show ${data_bag} ${data_bag_item} -f json > ${tmp_file_old} | |
jq -c ".id = \"${new_data_bag_item}\"" ${tmp_file_old} > ${tmp_file_new}.json | |
chef exec knife data bag from file ${data_bag} ${tmp_file_new}.json --encrypt | |
rm ${tmp_file_old} | |
rm ${tmp_file_new} | |
rm ${tmp_file_new}.json | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
copy_data_bag apps my_application my_application_staging
Requires: