David - Musings of an SRE

Some tips to deploying Rubber-powered EC2 Rails Apps

I’ve been playing around with Rubber, the EC2 deployment script for Rails lately and I’ve spent a huge amount of time trying to get it to work.

Here are some of my notes:

  1. To setup:
# Put this into Gemfile
gem rubber
  1. Vulcanize! (Create the deployment scripts according to your specifications) On Rails 3.x, in your Rails application’s root directory
davidc@davidc:~/my/awesome/app> vulcanize <option>

# with option being any one of the following
minimal_nodb, redis, passenger_nginx, complete_passenger_nginx, cruise, postgresql, resque, apache, 
sphinx, monit, minimal_passenger_nginx, mysql_cluster, complete_passenger_postgresql, cassandra, mongodb, 
complete_mongrel_mysql, complete_passenger_nginx_postgresql, base, memcached, minimal_mysql, 
complete_passenger_mysql, complete_passenger_nginx_mysql, munin, mysql_proxy, complete_passenger, 
mysql, nginx, jetty, passenger, haproxy, mongrel
  1. Edit /config/rubber/rubber.yml

  2. Use Alestic.com’s list of Ubuntu AMIs for the southeast region (Edit the image_type and image_id fields)

  image_type: t1.micro
  image_id: 'ami-5e215b0c'

Tip: Use t1.micro if you are on the Amazon AWS Free-tier.

  1. Create a keypair via your AWS EC2 Console. Make sure you’re creating the pair in the region that you’d like to launch your instances from. Once created, copy that private key into your ~/.ec2 directory (Create the folder if it doesn’t already exist)

  2. Your private key should be in the format of keypair-name.pem. Rename it to just keypair-name without the extension.

  3. In ~/.ec2, generate a public key that you’ll use with the following command.

# substitute gsg-keypair with the name of the private key that you've downloaded
ssh-keygen -y -f gsg-keypair > gsg-keypair.pub

Note: If you’re getting an “UNPROTECTED PRIVATE KEY FILE!” warning, do a chmod 400 before generating the public key.

  1. Make sure your server_endpoint field (/config/rubber/rubber.yml) is pointing to the correct endpoint. In my case, for a Singapore AWS instance, its:
server_endpoint: ap-southeast-1.ec2.amazonaws.com
  1. Modify the relevant /config/rubber/rubber-*.yml files to suit your needs

  2. ???

  3. Profit!

davidc@davidc:~/my/awesome/app> cap rubber:create_staging