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.
.gif?size=webview)
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.
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
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.

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

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.

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!

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.
Remember how difficult it was to launch a server the traditional way?
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.

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

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.

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

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

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

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

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.

Select the cloned ServerTemplate.

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.

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

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.

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
.

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.

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

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.

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

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.

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.
Now you can delete the old RightScripts.
Your ServerTemplate should now look something like this:

Congratulations! You now have a custom ServerTemplate that will build a new server with your MySQL database and Rails application.
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.

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.

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.

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

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!
| File | Size | Date | Attached by | |||
|---|---|---|---|---|---|---|
| sample_mysql_dump.gz No description | 691 bytes | 17:31, 13 Nov 2008 | deano | Actions | ||
| sample_rails_app.tgz No description | 453 bytes | 22:26, 13 Nov 2008 | deano | Actions | ||