Created
June 14, 2012 10:46
-
-
Save 164c/2929567 to your computer and use it in GitHub Desktop.
chefのnodeファイルのnameをファイル名と合わせるscript
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/sh | |
| BASE_DIR=/path/to/chef_nodes_dir | |
| for filepath in $BASE_DIR/*.json | |
| do | |
| filename=`basename $filepath` | |
| hostname=`echo $filename | sed -e "s/\.json//"` | |
| written_host=`grep "\"name\"" $filepath | awk '{print $2}' | sed -e 's/[,"]//g'` | |
| if [ $written_host != $hostname ] ; then | |
| sed -i -e "s/$written_host/$hostname/" $filepath | |
| fi | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nodeファイルはhostname.jsonという名前になってる前提で、同じroleのホストを大量に立てるときに使える可能性0.5%