Introduction

These Capistrano recipes allow you to automate the setup of a machine running Ubuntu Server 8.0.4, 8.1 or 9.0.4. They will install/setup : SSH, iptables, MySQL, Apache, PHP, Ruby (+ Ruby Enterprise Edition), Rails, Phusion Passenger, and Git.
It has been tested on a Slicehost slice, and on an OVH Real Private Server.

Why?

Installing and configuring a server can be a tedious task. Automating it allows you to re-install it in a breeze, or the install several servers with the exact same configuration.

What it does

Right now, theses recipes allow you to :

  • setup SSH
  • setup IPTables
  • perform a full update of the distro (with aptitude)
  • MySQL
    • install
    • start/restart/stop
    • create a new database with a new user, and upload a local .sql file to create the DB
    • dump a database and download the dump file locally
  • Apache
    • install
    • start/restart/stop/reload/force reload
    • list enabled sites/modules
    • list available sites/modules
    • enable/disable site/module
    • create a new Website
    • delete a Website
  • Ruby
    • Install Ruby 1.8
    • Install Ruby Enterprise Edition
    • Install Phusion Passenger
  • Install the latest version of Git
  • Install PHP5
  • Install Postfix

Download and install

Those recipes are available as a Ruby GEM. It is assumed that you already have Rubygems 1.3.1 and Capistrano 2.5.3 installed on your local machine.
The following commands are run on your local machine, not on the server.

You can install the Ubuntu Machine gem like this :

# Add GitHub to your gem sources
$ gem sources -a http://gems.github.com 

# Install the Ubuntu Machine gem
$ sudo gem install suitmymind-ubuntu-machine

To upgrade the already installed Ubuntu Machine gem, just run this :

# Make sure you have already done this :
# Add GitHub to your gem sources
$ gem sources -a http://gems.github.com

# Then update the installed gem
$ sudo gem install suitmymind-ubuntu-machine

Use it

Once the Ubuntu Machine gem is installed, create a directory and capify it :

$ mkdir my_new_server
$ cd my_new_server
$ capify .

You must then create a deploy.rb file where you'll store your configuration information.
You can download a template for this file like this :

$ cd my_new_server
$ git clone git://gist.github.com/41297.git config

If you don't want to use Git, you can also simply copy this template from here, and create a file called deploy.rb in a 'config' directory under the 'my_new_server' directory.

Then, to configure the machine, simply run :

$ cd my_new_server
$ cap machine:initial_setup
$ cap machine:configure
$ cap machine:install_dev_tools

Watch the screencasts

Setup a brand new Ubuntu machine (change root password, add a new user, remove root from authorized ssh users, setup iptables, ssh, update the distro, install Apache, MySQL, Ruby Enterprise Edition, Rails, Passenger, PHP, create a new Website, create a new database) :

Download the iPhone version or the full quality version.
The config files have changed a little bit since the screencast, so you'll notice small differences, but you'll still get the idea.

Changelog

  • 0.5.3.1 - March 21st 2009 :
    • Add a ruby:upgrade_passenger task (The commit : here)
    • Various minor bug fix
  • 0.4.9 - March 17th 2009 :
    • Use the Passenger (2.1.2) auto installer (non interactive), postfix:install task, use apt-get instead of aptitude (The commit : here)
    • modified deploy.rb template (download it here). You don't need to specify the version of Passenger anymore. The latest version is automatically installed.
  • 0.4.8 - March 10th 2009 :
    • Replace curl by wget cause it seems that curl is not always installed by default (The commit : here)
  • 0.4.1 - Feb 26th 2009 :
    • bypass interactive screen for mysql root password during mysql install (The commit : here)
  • 0.4.0 - Feb 6th 2009 :
  • 0.3.1.2 - Jan 31th 2009 :
    • Added optional SQL file upload when creating database.
    • The commits : here and here.
  • 0.3.1.1 - Jan 21th 2009 :
    • Added passenger commands for status, memory, and enterprise activation
    • The commits : here, here and here.
  • 0.3.1 - Jan 18th 2009 :
    • REE is added to the default path (tickets : #12 and #13)
    • REE updated to the latest version : ruby-enterprise-1.8.6-20090113 (you should update your deploy.rb file accordingly or re-download it from here.)
    • The GitHub commit
  • 0.3.0 - Jan 15th 2009 :
  • 0.2.0 - Jan 7th 2009 :
    • first public release

About

The Ubuntu Machine Capistrano recipes have been inspired by Jamis Buck's Capistrano, based on Josh Peek's recipes and developed by Thomas Balthazar.
Ubuntu Machine is released under the MIT license