Created
February 16, 2012 00:02
-
-
Save assaf/1840224 to your computer and use it in GitHub Desktop.
Deploy using chef-solo
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
# Run command(s) over SSH | |
run() { | |
ssh deploy@${HOST} -t $* || exit 1 | |
} | |
# Transfer all the specified files/directories to working directory | |
upload() { | |
tar czf - $* | ssh deploy@${HOST} tar xzf - -C /etc/chef || exit 1 | |
} | |
# solo.rb tells chef-solo where to find cookbooks, roles and data bags and. | |
cat > /tmp/solo.rb <<-RB | |
file_cache_path "/tmp/chef" | |
cookbook_path "/etc/chef/cookbooks" | |
role_path "/etc/chef/roles" | |
data_bag_path "/etc/chef/data_bags" | |
log_level :info | |
RB | |
cat > /tmp/chef.json <<-JSON | |
{ "instance_role": "my_app", | |
"run_list": ["role[my_app]"] | |
} | |
JSON | |
echo Creating working directory ... | |
run sudo rm -rf /etc/chef \;\ | |
sudo mkdir -p /etc/chef \;\ | |
sudo chown deploy:deploy /etc/chef \;\ | |
sudo rm -rf /tmp/chef \;\ | |
mkdir -p /tmp/chef | |
echo Uploading cookbooks and related files ... | |
cd /tmp ; upload chef.json solo.rb | |
cd - ; upload cookbooks data_bags roles | |
echo Running Chef solo ... | |
run sudo /usr/bin/chef-solo -c /etc/chef/solo.rb -j /etc/chef/chef.json | |
growlnotify -t Chef -m "Deployed to ${HOST}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A really useful one. Thanks!