Automatic Rails Applications

The following article was written for the FiveRuns blog. FiveRuns makes Ruby on Rails performance and monitoring tools. With the release of Dash, they’ve extended the tool set to include more frameworks and social networking integration. Very cool stuff.

A few additional notes on the article:

  • Use a hostname and not an IP in order to automatically install the Rails apps. This is because Passenger uses virtual hosts to direct traffic to each app.
  • Because this script configures production servers and not client development environments, I chose not download the Rails projects’ source to the client. This is simple to add via an additional git clone statement, but this way it runs faster and cleaner using only the config files that Capistrano needs.

Some potential future enhancements:

  1. Enter the password only once or pull it from a hash file
  2. Alternately, install a key pair to the new server automatically so the password isn’t needed after the first ssh connection.
  3. Add additional Rails applications
  4. Add an option to provide the installed Rails application’s dynamically. That is, the menu could prompt for target repository url, deploy.rb, database.yml, etc. instead of using predefined, included app config files.

The Original Article Follows:

Welcome to the third installment of configuration-automation, a Ruby on Rails environment setup script. We’ll take a remote Linux server from first boot to fully configured, live Rails application server with just a hostname and password. This version includes a menu of Rails applications to choose from and replaces the nginx/mongrel servers with Phusion Passenger. Four popular Rails applications: Radiant, Spree, jobberRails and El Dorado are available to be deployed automatically.

What’s Needed

All you need is Capistrano and git installed on your *nix client to download and execute the scripts. On the remote server, Ubuntu 8.04 or 8.10 with ssh listening is supported, such as a Slicehost VM or VMWare image.

Using The Script

Just download the files from github and run:
git clone git://
cd ./configuration-automation
git checkout -b origin/production-v1

What Happens

An ssh connection to the Ubuntu server updates core system libraries and installs dependencies such as Ruby and MySQL. The Rails application chosen is deployed via Capistrano with a second ssh connection. Each connection requires the target server’s password or you can install an ssh key pair to skip those prompts.

To install additional Rails applications to the newly configured server, run from the same ./configuration-automation directory. The main script can also be rerun from the same directory against other blank Ubuntu targets.

Why Do This?

With no DSL to learn or manifests to build, this is a fast, simple way to bootstrap a Rails server. I built it to test (and quickly retest) compatibility with FiveRuns Manage and TuneUp product updates. As such, it makes a decent acceptance test environment builder. It is also a way to experiment with a functioning Ruby on Rails app server without working through every installation issue.

It’s not intended to meet the meet the same needs as more powerful tools like Puppet, or now Chef, though you could easily add these after running configuration-automation. For EC2 environments, also check out Matt Conway’s cool Rubber Capistrano/Rails plugin.

The Rails app versions are frozen to today to ensure their project updates don’t break the automation. I’ll refresh these in later updates to configuration-automation. Suggestions and feedback are welcome via comments below or on my blog.

Leave a Reply