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)
Now go to Design -> Servers -> Server Templates.
Server templates consist of a base image that contains 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 (beta)" server template, which will be used to launch one server on EC2 for hosting your Rails app and MySQL database.
This tutorial is divided into 7 steps:
Step 1: Launch a server on EC2 using a server template
Step 2: Overview of Server Templates
Step 3: Clone a Server Template
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 Server Template
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 -> Servers -> Server Templates.
Click on the RightScale tab to see a list of publicly available server templates from RightScale and select the latest version of the "Rails all-in-one -s3" server template.
Now click the Launch button.

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

Accept the default input parameters for the server and click the Launch button.

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 server templates and how they work, as well as show you how to clone and modify a server template 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 server templates to help automate this whole process. It provides a very flexible way of configuring servers without ever touching a piece of hardware and also guarantees a consistant configuration across all servers, including new servers that are added your deployment.
Each server template can also be cloned and modified for all types of custom configurations.
Let's take a closer look at a server template's configuration.

The Info tab describes some of the basic details about each server that is built with the server template.
The Scripts tab lists all of the RightScripts (boot and operational 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 v4" boot script.

If you click on the Scripts tab, you'll see that it's just a normal bash script (although it could have been written in any 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 "syslog-ng-remote.conf" attachment is called in the 5th line.

Upload files through the Dashboard and then reference them in your script by adding $RS_ATTACH_DIR/ as a prefix to the file name.
Go back to the server template's homepage (Design -> Servers -> Server Templates).
Finally, click on the Inputs tab to see a list of all of the inputs for the server template. Since, this is a public server template, you cannot edit any of these inputs. Later on in this tutorial, we'll show you how to clone a public server template so that you can customize its input parameters.

Now that you've seen how easy it is to launch a server and have a basic understanding of server templates, 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 server templates and 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 server template than creating a new server template from scratch.
To clone a server template, go to Design -> Servers -> Server Templates. Select the "Rails all-in-one -s3 (beta)" server template.

Click the Clone button to make a copy of the server template.

Click on Server Templates in the navigation menu and you should now see a clone of the "Rails all-in-one -s3 (beta)" server template under the Private tab. Select the cloned server template.

Now, let's change the name of the server template to avoid any possible confusion with the original server template. To change the name, click on the server template's name. 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 (ex: mysql_db.gz) 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 app, go back to Public tab (Design -> Servers -> Server Templates) the click on the magnifying glass of "RB rails attachment code update & db config v1 (beta)" and click the Clone button.

Rename the cloned RightScript "Rails App (clone)." Click on the Attachments tab. You'll notice that the original RightScript that we just cloned already had an application for our photo demo site. Since, you're going to upload your own Rails application, you can remove it by clicking the remove button
.

To attach your own Rails application to the cloned RightScript, browse for your Rails app file (ex: rails_app.gz) and click Upload. Depending on the file's size, it may take several minutes to upload your Rails app.

Now that you've cloned, renamed, and attached a dump of your RailsApp to the "RailsApp (clone)" RightScript, the last step is to replace the existing RightScripts in the "Rails Clone" server template with the new RightScripts that you just created.
Go back to Design -> Servers -> Server Templates and select the "Rails Clone" server template.
Before we can launch the server template, we need to update our list of RightScripts so that it uses the new RightScripts that you just created. Click on the Scripts tab.

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 & drap it in the new location.

Now you can delete the old RightScripts. Click the remove button
.
Congratulations! You now have a custom server template 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:
Click Save.
You are now ready to launch your custom Rails All-In-One server!
Go back to Design -> Servers -> Server Templates.

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, go to the Dashboard homepage (Shortcut: click the RightScale logo) 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 server templates 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!