Created
February 17, 2012 21:29
-
-
Save rkive/1855580 to your computer and use it in GitHub Desktop.
Remotely push chef-solo and run it.
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 | |
# runChefSolo.sh | |
# Author: abento+github@gmail.com | |
# Setup a set of cookbooks using chef-solo on a remote machine. | |
hostname="" | |
domain="" | |
cookbook_root="." | |
file_root="./provisioning/chef-solo" | |
tmp_root="./provisioning/tmp" | |
pushConfig() | |
{ | |
echo "Pushing chef-solo config to host $1" | |
scp $file_root/solo.rb $1: >/dev/null 2>&1 | |
scp $file_root/runlist.json $1: >/dev/null 2>&1 | |
echo "Taring up cookbooks..." | |
COPYFILE_DISABLE=1 tar zcLf $tmp_root/solo_cookbooks.tgz cookbooks | |
if [ $? -ne 0 ]; then | |
echo "Problems creating tarball." | |
exit 1 | |
fi | |
scp $tmp_root/solo_cookbooks.tgz $1: >/dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo "Problems push tarball to $1." | |
exit 1 | |
fi | |
} | |
runChefSolo() | |
{ | |
echo "Running chef-solo on host $1" | |
ssh -t $1 "sudo chef-solo -c ./solo.rb -j ./runlist.json -r ./solo_cookbooks.tgz" | |
} | |
if [ "$1" ] | |
then | |
pushConfig $1 | |
runChefSolo $1 | |
else | |
for host in $hostname.$domain; do | |
pushConfig $host | |
runChefSolo $host | |
done | |
fi | |
echo "chef-solo push and config run complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment