Install recipes for quick server setup

This bunch of recipes is aimed to help you with automatical server setup. No handjob required.

Serverside

Assuming you have root priveligies:

Add new user
useradd -m [username] -s /bin/bash
Grant access rights to new user

Run visudo and add:

username ALL=(ALL:ALL) NOPASSWD: ALL
Remote repo keys

Add remote repo keys to users .ssh/known_hosts to avoid requests while running cap procedures Git:

cap system_user:copy_ssh_keys

Clientside

Add recipes
git submodule add git@github.com:linko/cap-recipes.git
cd cap-recipes && git checkout recap
Copy files
cp cap-recipes/Capfile.recap.example ./
mkdir config/deploy
cp cap-recipes/config/deploy/* ./config/deploy/
Update your .gitignore

Add here

config/unicorn.rb
.recap-lock
/cap-recipes
Update Gemfile

Copy everything from Gemfile.example to your Gemfile and run bundle install

Check needed recipes to be included

Verify you'd included correct recipes for your application (i.e. mysql recipe for application on postgres) in Capfile. For example:

set :recipes_dir, File.expand_path('/cap-recipes', __FILE__)
load recipes_dir + '/config/recipes/base'
load recipes_dir + '/config/recipes/nginx'
load recipes_dir + '/config/recipes/unicorn'

Setup instructions

bundle exec cap deploy:install
bundle exec cap bootstrap
bundle exec cap deploy:setup

#####Comment recipes loading Open Capfile and comment part with recipes loading

set :recipes_dir, File.expand_path('/cap-recipes', __FILE__)
load recipes_dir + '/config/recipes/base'
load recipes_dir + '/config/recipes/nginx'
load recipes_dir + '/config/recipes/postgresql'
load recipes_dir + '/config/recipes/rbenv'
load recipes_dir + '/config/recipes/unicorn'

#####Final deploy

bundle exec cap deploy

Rolling back

bundle exec cap deploy:rollback

Known issues

  • MySQL limitation to 16 symbols username can cause a problem in mysql recipe. To avoid this edit line set_default(:db_user) { "#{application}_production" } to get in this limit.