Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

smartlogic/chef-cap-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intoduction

This project provides an example of setting up a server with Chef and deploying a Ruby on Rails application do it with Capistrano

Getting Started

  1. Install VirtualBox
  2. Install Vagrant
  3. git clone [email protected]:smartlogic/chef-cap-demo.git
  4. cd chef-cap-demo
  5. bundle install
  6. vagrant up
  7. vagrant ssh-config --host chef_cap_demo >> ~/.ssh/config

Chef

  1. cd chef-repo
  2. 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

  1. bundle exec knife bootstrap -p 2222 -x vagrant -d precise32_vagrant chef_cap_demo
  2. 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

Chef cookbook for the app

Create a chef cookbook for your application

  1. git checkout app_cookbook
  2. bundle exec knife cook vagrant@chef_cap_demo

ssh -l chefcapapp chef_cap_demo

Capistrano

Setup Capistrano

  1. cd ..
  2. git checkout cap_setup
  3. bundle
  4. bundle exec cap chef_cap_demo deploy:setup deploy:migrations

Capistrano tasks

Create a capistrano task to run our rake task as part of deploy

  1. git checkout cap_data
  2. bundle exec cap chef_cap_demo deploy

Proof

  1. Open http://localhost:8080
  2. See the messages left by Chef and Capistrano
  3. cd chef-repo
  4. bundle exec knife cook vagrant@chef_cap_demo
  5. Refresh http://localhost:8080
  6. Observe a new message from the Chef run
  7. cd ..
  8. bundle exec cap chef_cap_demo deploy
  9. Refresh http://localhost:8080
  10. Observe a new message from the Capistrano run
  11. Both Chef and Capistrano created and will maintain a singleton entry that is not duplicated by additional runs

Starting over

  1. vagrant destroy
  2. vagrant up
  3. Back to the Chef section