[ANN] Machinify: Stack Toolkit

Written By : Bradley Taylor

May 25, 2007

After RailsConf, DHH announced a new mailing list for Rails stacks. After watching a day of posts, I decided to force myself to finally implement some ideas for a simple, dependency-driven toolkit for assembling and installing stacks based on Rake. I hope this gem can grow to support a variety of packages, stacks, and operating systems.

Over the past year, the Rails Machine stack has been deployed on over 400 virtual servers for our hosting customers and a number of customers of our commercial support offerings. I don’t know exactly how many Rails applications this is, but 1000ish would be a reasonable guess. Starting with this gem and a series of releases to follow, I would like to see the stack have a life outside of our firewalls!

This first release lays the foundation for building stacks with different components and different platforms with a common interface. For this release, I’ve provided foundational tasks for installing Apache 2.2, Mongrel, mongrel_cluster, Rails, and MySQL on Ubuntu Feisty Fawn.

To get up and running, execute the following:

sudo aptitude install -y ruby rubygems
sudo gem update --system
sudo gem install rake machinify
machinify .
rake stack:install

If you need RMagick, you can run rake imagemagick:install. There are a number of tasks available for installing a single package, server role (web, app, db), and basic service management commands. Tasks include:

rake apache:install               # Installs apache with worker mpm
rake apache:restart               # Restarts the apache process
rake imagemagick:install          # Installs ImageMagick and RMagick
rake mongrel:cluster:install      # Installs scripts for managing mongrel clusters
rake mysql:client:install         # Install mysql client and library
rake mysql:server:install         # Install mysql and ruby library
rake mysql:server:restart         # Restarts the mysql process
rake rails:install                # Installs rails
rake stack:install                # Installs a full web application stack
rake svn:install                  # Installs Subversion revision control system

In addition, there are package independent tasks that will be configurable in an upcoming release:

rake web:install                  # Installs web server stack
rake web:restart                  # Restarts the web server process
rake db:client:install            # Installs database client stack
rake db:server:install            # Installs database server stack

Run rake -T to see the full list. You can also create your own stacks with custom tasks.

Some may wonder why I didn’t write this using Capistrano like other deployment gems. Personally, I feel that Capistrano is a user interface to ssh. It is the “view” in MVC. It is an excellent system for invoking commands over SSH and an amazing piece of code. However, it is very easy to try to solve every problem using it including but not limited to automated deployment, stack installation, virtual machine creation, and global warming. If cap is the view, then rake on the server is the controller. Think of tasks like Rails actions. By refactoring the code to the server, you can create APIs over SSH. This approach allows a single cap recipe to execute commands on servers with different operating systems and stacks installed. A cap task that calls “rake stack:install” can be completely ignorant of the details of the server. For example, cap web:restart could call rake web:restart and not care if the server was running Apache, Nginx, Linux, or OpenSolaris. Expect updates to the railsmachine gem to reflect this approach.

Some may also wonder why Ubuntu. I’ve used Ubuntu everyday as my work desktop for almost nine months. I’d be lying if I didn’t admit to missing some niceties from my Macs. However, Ubuntu is extremely usable and the gains of open source outweigh some of the annoying rough edges. I’ll also be speaking at Ubuntu Live (Use code ubu07ucm for a 35% discount).

Our software development road map is very exciting as we hope to continue innovating and contributing to Rails adoption and deployment.

  • Add Rails Machine special sauce to the base stack install on Ubuntu.
  • Complete CentOS 5 stack and rake tasks
  • Release updated railsmachine and mongrel_cluster gems (bug fixes, new features, Cap 2 compatible).
  • Add support for process monitoring, log rotation, session cleanup, and Nginx.
  • Offer Ubuntu Server for hosting customers.
  • Release free Rails Machine virtual appliances (codename: Banshee). Downloads for KVM/Qemu, Parallels, Xen, and VMWare will be available.

If you are on Linux desktop, you must try KVM for development testing. Its amazing. Virtualization doesn’t get easier. On Ubuntu, you can install the package and launch an instance with two commands.

sudo aptitude install kvm qemu
sudo kvm -hda machinify.img -m 384