Automatic Rails Applications

February 23 2009, 10:16am

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://github.com/mmond/configuration-automation.git cd ./configuration-automation git checkout -b origin/production-v1 sh configure_ubuntu.sh

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 configure_rails_apps.sh from the same ./configuration-automation directory. The main script can also be rerun from the same directory against other blank Ubuntu targets.

And Why?

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 site.