Need help with chef-repo?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

425 Stars 87 Forks MIT License 600 Commits 32 Opened issues


Set up your server to host Ruby on Rails apps. - Follow us on Twitter: @intercityup

Services available


Need anything else?

Contributors list

Intercity Chef Recipes

Codeship Status for intercity/chef-repo

This Chef repository aims at being the easiest way set up and configure your own Rails server to host one or more Ruby on Rails applications using best practices from our community.

The configuration is heavily inspired by blog posts and chef recipes from 37signals and the Opscode Community Cookbooks.


Takes care of automatic installation and configuration of the following software on a single server or multiple servers:

  • nginx webserver
  • Passenger or Unicorn for running Ruby on Rails
  • Multiple apps on one server
  • Database creation and password generation
  • Easy SSL configuration
  • Deployment with Capistrano
  • Configure ENV variables
  • Easy backup scheduling

Supported OSes

  • Ubuntu 12.04 LTS
  • Ubuntu 14.04 LTS


  • MySQL
  • PostgreSQL

Getting started

The following paragraphs will guide you to set up your own server to host Ruby on Rails applications.

1. Set up this repository

Clone the repository onto your own workstation. For example in your

$ cd ~/Code
$ git clone git:// chef_repo

Run bundle:

$ bundle install

Run Librarian install:

$ librarian-chef install

2. Install your server

Use the following command to install Chef on your server and prepare it to be installed by these cookbooks:

bundle exec knife solo prepare @

This will create a file


Now copy the the contents from the

from this repository into this new file. Replace the sample values between
< >
with the values for your server and applications.

When this is done. Run the following command to start the full installation of your server:

bundle exec knife solo cook @

3. Deploy your application

You can deploy your applications with Capistrano.

Add the Capistrano gem to your Gemfile:

# your other gems..

gem 'capistrano', '> 3.2.1' gem 'capistrano-rails', '> 1.1'

And run bundle to install it:


Now generate configuration files for Capistrano:

bundle exec cap install

This command will generate the following files in your application:


Edit the file

and change it's contents to:
# Load DSL and Setup Up Stages
require 'capistrano/setup'

Includes default deployment tasks

require 'capistrano/deploy'

require 'capistrano/rails'

Loads custom tasks from `lib/capistrano/tasks' if you have any defined.

Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

Then edit

and change it to the sample below. Replace
>> your git repo_url <<
with the SSH clone URL of your repository:
# config valid only for Capistrano 3.2.1
lock '3.2.1'

set :application, '>> your_application_name <> your git repo_url <> your_application_name <<_production use agent forwarding for ssh so you can deploy with the key on your workstation. set :ssh_options forward_agent: true default value :pty is false :linked_files .rbenv-vars .ruby-version :linked_dirs tmp vendor public :default_env path: :keep_releases namespace :deploy do desc application task :restart roles in: :sequence wait: execute :touch release_path.join end after :publishing>

Replace the contents of

server '>> your server address <


>> your server address <<
with the domain name or ip address of your server.

To verify that everything is set up correctly run:

bundle exec cap production deploy:check

Finally to deploy, run:

bundle exec cap production deploy

This will deploy your app and run your database migrations.

Congratulations! You've now deployed your application. Browse to your application in your webbrowser and everything should work!

Try these cookbooks with Vagrant

You can use Vagrant to experience how easy it is to install your servers with this repository.

First, install Vagrant from Then install the following two Vagrant plugins:

Make sure you have Vagrant version 1.6.5 or higher installed.

vagrant plugin install vagrant-librarian-chef
vagrant plugin install vagrant-omnibus

Finally, start a Vagrant machine with a sample server configuration:

vagrant up mysql

This will boot a local Ubuntu virtual machine and install it so you can deploy Ruby on Rails applications that use MySQL as the database.

You can check out the sample configuration in file


When you run into problems:

These steps should let you set up or test your own Rails infrastructure in 5 - 10 minutes. If something doesn't work or you need more instructions:

Please! Open an issue or email [email protected].

Testing with test-kitchen

CI testing

Test-kitchen is a tool where you can automatically provision a server with these cookbooks and run the tests for them. The configuration in

works with DigitalOcean.

First you need to obtain a DigitalOcean access token here: Then you need to find IDs of the SSH keys you added to your account: You can obtain these IDs with the following command:

$ curl -X GET -H "Authorization: Bearer "

When you've obtained both your access token and your key IDs you can run the tests like this:

$ bin/kitchen test

This command boots up a Droplet in your DigitalOcean account, provisions it with Chef, runs the tests and destroys the Droplet.

Testing while developing

If you want to keep the Droplet running and do testing while making changes you can use the

kitchen verify
command instead of the
kitchen test
command to verify your changes:
$ bin/kitchen verify

Resources and original authors

  • Most of the cookbooks that are used in this repository are installed from the Opscode Community Cookbooks.
  • The
    configuration is based off the cookbooks by jsierles at

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.