This project provides an example of setting up a server with Chef and deploying a Ruby on Rails application do it with Capistrano
- Install VirtualBox
- Install Vagrant
git clone [email protected]:smartlogic/chef-cap-demo.git
cd chef-cap-demo
bundle install
vagrant up
vagrant ssh-config --host chef_cap_demo >> ~/.ssh/config
cd chef-repo
bundle install
Vagrant boxes already have chef installed, but lets install with our own bootstrap
file to provide a good example for when you aren't using Vagrant.
See chef-repo/.chef/bootstrap/precise32_vagrant.erb
to see how Chef gets installed
bundle exec knife bootstrap -p 2222 -x vagrant -d precise32_vagrant chef_cap_demo
bundle exec knife cook vagrant@chef_cap_demo
Check to see if you can login as the deploy user
ssh -l deploy chef_cap_demo
Create a chef cookbook for your application
git checkout app_cookbook
bundle exec knife cook vagrant@chef_cap_demo
ssh -l chefcapapp chef_cap_demo
Setup Capistrano
cd ..
git checkout cap_setup
bundle
bundle exec cap chef_cap_demo deploy:setup deploy:migrations
Create a capistrano task to run our rake task as part of deploy
git checkout cap_data
bundle exec cap chef_cap_demo deploy
- Open http://localhost:8080
- See the messages left by Chef and Capistrano
cd chef-repo
bundle exec knife cook vagrant@chef_cap_demo
- Refresh http://localhost:8080
- Observe a new message from the Chef run
cd ..
bundle exec cap chef_cap_demo deploy
- Refresh http://localhost:8080
- Observe a new message from the Capistrano run
- Both Chef and Capistrano created and will maintain a singleton entry that is not duplicated by additional runs
vagrant destroy
vagrant up
- Back to the Chef section