Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Deploy using chef-solo

View deploy.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# 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
 
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
vaskas commented

A really useful one. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.