Objective

This tutorial will introduce you to some of the key concepts behind the RightScale platform and also show you how easy it is to deploy your Rails application on EC2.  Use the RightScale Dashboard to set up, customize, and monitor all of your AWS activities. 

This tutorial can be done on any type of account (Free Trial, Developer, Premium).

If you are using a free trial account, you must activate your trial account by clicking on the link that was emailed to you from notifier@my.rightscale.com.

You'll notice that our Help screens will automatically appear by default.  If you wish to hide the help screens, simply click  the Hide Help button.

rails_diagram_v1 (1).gif

Go to Design -> ServerTemplates. 

ServerTemplates consist of a base image that contain a light-weight Linux installation (in this case, CentOS ) and some scripts that help customize the image's configuration. In this tutorial you will be using the "Rails all-in-one -s3" server template, which will be used to launch a server on EC2 for hosting your Rails application and a MySQL database.

This tutorial is divided into 7 steps:
Step 1: Launch a server on EC2 using a ServerTemplate
Step 2: Overview of ServerTemplates
Step 3: Clone a ServerTemplate
Step 4: Clone a RightScript and Upload your MySQL Database
Step 5: Clone a RightScript and Upload your Rails Application
Step 6: Replace RightScripts in Cloned ServerTemplate
Step 7: Launch the Server
     

Step 1: Launch a server on EC2 using a server template

First, let's see how easy it is to launch a new instance on EC2 with RightScale. 

Go to Design -> ServerTemplates. Click on the RightScale tab.  You will see a list of publicly available ServerTemplates from RightScal.  Use the "Filter by Nickname" tool to find the most recent version of the "Rails all-in-one -s3" ServerTemplate. Click the Launch button to launch a server using the "Rails all-in-on -s3" ServerTemplate.

rails_allinone_33_launch_template.gif

 

Confirm that you want to launch a server and click the Launch button.

rails_allinone_34_confirm_launch.gif

 

Next you will see a list of input parameters that can be defined for the server.  Required inputs will be highlighted in pink.  Select dedicated as the input and click the Launch.

rails_allinone_35_usage.gif

 

Congratulations!  You've just configured and launched a server on Amazon's EC2 using one of RightScale's server templates.  Of course, you will have to wait a couple of minutes for the server to boot and become fully operational, but it's really that easy!   

rails_allinone_37_deployment.gif

In the next two steps we'll give you an overview of ServerTemplates and how they work, as well as show you how to clone and modify a ServerTemplate for your own for a custom configuration. 

Troubleshooting

If you receive an error message saying that "Your account has insufficient funding to perform this action," you first need to activate your account.  Check your email for a message from notifier@my.rightscale.com and click on the link to validate your email and start your trial account.

 

Step 2: Overview of ServerTemplates

Remember how difficult it was to launch a server the traditional way?

  1. Perform a clean installation of your favorite OS
  2. Install and configure the required programs
  3. Launch, Fail, Debug, Repeat.

Sound familiar?   Now, with cloud computing, you can dynamically launch virtual servers with the click of a button!

RightScale created ServerTemplates to help automate this whole process.  It provides a very flexible way of configuring servers without ever touching a piece of hardware.  It also guarantees a consistant configuration across all servers, including new servers that are added your deployment.

Each ServerTemplate can also be cloned and modified for all types of custom configurations.  

Let's take a closer look at a ServerTemplate's configuration.  Click the Rails all-in-one -s3 template.

rails_allinone_38_select_template.gif

 

 

The Info tab describes some of the basic details about each server that is built with the ServerTemplate.

rails_allinone_39_template_info.gif

  • Instance type - size of the server (m1.small is about a 2GHz processor with about 2GB RAM)
  • Image - type of Linux image, kernal, and ramdisk
  • DNS addressing type - define whether you want the server to be addressable externally on the Internet, or internally on a LAN.
  • User data - there are two fields for entering user-defined data that you want to be passed to the instance when it is launched.
  • Launch data -

 

The Scripts tab lists all of the RightScripts (boot, operational, and decommissioning scripts) for each server.  To view or modify a script, click on a script's magnifying glass.  For example, click on the "SYS Syslog Remote Logging Client" boot script.

rails_allinone_40_show_script.gif

 

If you click on the RightScript's Script tab, you'll see that it's just a normal bash script (although it could have been written in any scripting language).  

rails_allinone_36_script.gif

 

  • Packages - lists any packages that will be installed before the script is run.
  • Inputs - lists any input parameters that will be set before the script is run.  Ex: "SYSLOG_SERVER" - Notice the Dashboard automatically recognized $SYSLOG_SERVER as a variable in the script's code. 

Now click on the Attachments tab to see which files are used in this script.  Ex: "syslog-ng-remote.conf" 

rails_allinone_41_show_attachments.gif

If you go back to the Scripts tab, you'll notice that the attached file (syslog-ng-remote.conf) is referenced near the top, where the $RS_ATTACH_DIR environment variable is utilized.

Upload files through the Dashboard and then reference them in your script by adding $RS_ATTACH_DIR/ as a prefix to the file name.

Now go back to the "Rails all-in-one -s3" ServerTemplate to see all of its inputs.

 

rails_allinone_42_jump.gifA quick way to go back to a recently viewed ServerTemplate, Deployment, RightScript, is to hover your cursor over the expansion triangle and select your object.

 

Select the template's Inputs tab.  Hover over the info icon to see a more detailed description about each input.

rails_allinone_43_view_inputs.gif

Since, this is a public ServerTemplate, you cannot edit any of these inputs.  Later on in this tutorial, we'll show you how to clone a public ServerTemplate so that you can customize its input parameters.

 

 

Step 3: Clone a ServerTemplate

Now that you've seen how easy it is to launch a server and you have a basic understanding of ServerTemplates themselves, we'll show you how easy it is to get your own application up and running on EC2 with RightScale.

Prepare your MySQL Database and Rails Application

  • Take a dump of your MySQL database and save it as a gzip file.
  • Take a gzipped tar of the root directory of your Rails application.


The Dashboard allows you to clone ServerTemplates, RightScripts which gives you the flexibility to modify and reuse components to save time and effort when deploying your application.  It's easier to clone and modify an existing ServerTemplate than creating one from scratch.

To clone a ServerTemplate, go to Design -> ServerTemplates.  Select the RightScale tab.  Either page down, or use the "Filter by Nickname" feature (enter "Rails" an click on Apply) to select the latest "Rails all-in-one -s3" Server Template.

rails_allinone_44_rails.gif

 

Click the Clone button to make a copy of the ServerTemplate.  When you clone a ServerTemplate, the clone (copy) can be found under the Private tab.

rails_allinone_45_clone.gif

 

Select the cloned ServerTemplate.

rails_allinone_46_select_clone.gif

 

Now, let's rename the ServerTemplate to avoid any possible confusion with the original template.  To change the name, click on the name and rename it "Rails Clone" and click Save.

rails_allinone_47_rename.gif

Step 4: Clone a RightScript and Upload your MySQL Database

The next step is to upload your Rails app and database using RightScripts.  Click on the Scripts tab. 

 

rails_allinone_48_import_script.gif

First we'll clone the mysqldump RightScript so that we can edit it and attach a dump of our own MySQL database. Click on the magnifying glass of "DB MySQL mysqldump import without s3 (beta)" and click the Clone button.

 

rails_allinone_49_clone_script.gif

Rename the cloned RightScript "MySQL DB (clone)."

Click on the Attachments tab.  You'll notice that the original RightScript that we just cloned had a MySQL database for our photo demo site.   Since, you're going to upload your own database, you can remove the existing database by clicking the remove button rails_allinone_20.gif

rails_allinone_50_remove_att.gif

To attach a new MySQL-DB, browse for the dump of your MySQL database file or you can use our sample dump file "sample_mysql_db.gz" (see attachments below) and click Upload.  Depending on the file's size, it may take several minutes to upload your dump file.

rails_allinone_51_sample_dump.gif

Now that you've cloned, renamed, and attached a dump of your MySQL-DB to the "MySQL-DB (clone)" RightScript, you'll need to repeat this process for your Rails application.

Step 5: Clone a RightScript and Upload your Rails Application

To upload the Rails application, navigate again to  Design -> ServerTemplates.  Select your "Rails Clone" ServerTemplate and go to the Scripts tab.  Click on the magnifying glass of RB rails attachment code update & db config v1 (beta)

rails_allinone_53_code_script.gif

Finally, click the Clone button to create an editable copy of the script, which will appear under your Private tab.

Rename the cloned RightScript "Rails App (clone)."  Click on the Attachments tab. Remove the attached application ("app.tgz") so you can upload your own application.   Browse and upload your own Rails application or use our sample_rails_app.gz (see attachments below).  Depending on the file's size, it may take several minutes to upload your Rails app.

rails_allinone_54_upload_app.gif

To attach your own Rails application to the cloned RightScript, browse for your Rails app file (ex: rails_app.gz) and click Upload.

Now that you've cloned, renamed, and attached a dump of your Rails Application to the "RailsApp (clone)" RightScript, the last step is to replace the existing RightScripts in your "Rails Clone" ServerTemplate with the new RightScripts that you just created.

Step 6: Replace RightScripts in Cloned ServerTemplate

Navigate back to Design -> ServerTemplates and select the "Rails Clone" ServerTemplate in the Private tab. 

Before we can launch a new server with the ServerTemplate, we need to update our list of RightScripts so that it uses the new RightScripts that you just created.  Click on the Scripts tab.

Replace the old scripts with the new ones.

rails_allinone_55_replace_scripts.gif

In order to ensure that the correct order of RightScripts is maintained, it's better to first add the new RightScripts and place them in the correct order before deleting the old RightScripts.

At the bottom of the page, select the "MySQL DB (clone) and add the RightScript as a boot script.

rails_allinone_27.gif

Now add the "RailsApp (clone)" RightScript as a boot script.  You'll notice that the new scripts were added to the bottom of the Boot Scripts list.  

To change the order of a script, simply click on the name of the script and drag & drop it in the new location.

  • Drag and drop the new "MySQL DB (clone)" RightScript above the "DB MySQL mysqldump import without s3 (beta)."
  • Drag and drop the new "RailsApp (clone)" RightScript above the "RB rails attachment code update & db config v1 (beta)."

Now you can delete the old RightScripts.

  • Delete "DB MySQL mysqldump import without s3 (beta)."
  • Delete "RB rails attachment code update & db config v1 (beta)."

Your ServerTemplate should now look something like this:

rails_allinone_56_new_list.gif

Congratulations!  You now have a custom ServerTemplate that will build a new server with your MySQL database and Rails application.

 

Step 7: Launch the Server

Before you launch the server, you'll need to change some of the input parameters of the "Rails Clone" server template.  Click on the Inputs tab.  Now click the Edit link to edit the input parameters.

rails_allinone_29.gif

 

Modify the following input parameters accordingly:

 APPLICATION  Text Change the name to better describe your application.  (ex: My First Rails App on EC2)
 APPLICATION_FILENAME  Text Change (if needed) the filename so that it matches the name of your Rails application that you included as an attachment earlier.  (ex: sample_rails_app.gz)
 DB_MYSQLDUMP_FILENAME  Text Type the name of your MySQL dump file.  If you are using our sample dump file, use "sample_mysql_dump.gz"
 DB_SCHEMA_NAME  Text Change the name so that it matches the schema of your database.  (ex: mysql_db)
 DB_SERVER_USAGE  Select text: dedicated
 OPT_GEMS_LIST  Text (Optional)  If your application requires additional gems, you can list them  (space-separated) in this field.  (ex: rcov right_aws rexml)

 

Click Save

You are now ready to launch your custom Rails All-In-One server!  Click the Launch button and confirm your server settings. 

rails_allinone_57_launch.gif

In a few minutes your custom Rails server will be launched on an EC2 server instance.  Once your server finishes booting, you will receive an email from RightScale notifying you that your instance is now operational. 

rails_allinone_58_operational.gif

To preview your server in a browser window, click on the running server and click on your server's DNS address.

rails_allinone_59_dns.gif

 

Congratulations!  You've just seen how easy it is to launch your Rails application and MySQL database on an EC2 instance using RightScale's ServerTemplates and RightScripts.

 

 ----------------------

Did you find this document helpful?  Please feel free to leave us a comment below.  We're always looking for ways  to improve our documentation.  Thanks!

 

Tag page

Files 2

FileSizeDateAttached by 
 sample_mysql_dump.gz
No description
691 bytes17:31, 13 Nov 2008deanoActions
 sample_rails_app.tgz
No description
453 bytes22:26, 13 Nov 2008deanoActions
Viewing 1 of 1 comments: view all
Has anyone tried this template lately? It seems not to work. The Attachment Code does not work at all and it strands after boot. Maybe I am just missing something? Also, ruby is out of date with this and mongrel complains.
Posted 21:58, 18 Oct 2008
Viewing 1 of 1 comments: view all
You must login to post a comment.