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

rails_diagram_v1 (1).gif

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
     

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

rails_allinone_03.gif

 

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

rails_allinone_11.gif

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

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

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.

Step 2: Overview of Server Templates

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

rails_allinone_04.gif

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

  • Image - type of Linux image, kernal, and ramdisk
  • Instance type - size of the server (m1.small is about a 2GHz processor with about 2GB RAM)
  • 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.

 



 

 

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.

rails_allinone_05.gif

 

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

rails_allinone_07.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 $SYSLOG_SERVER variable in the script's code.  The Dashboard will automatically recognize any variable that is capatilized. 

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.

rails_allinone_08.gif

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.

rails_allinone_09.gif

 

Step 3: Clone a Server Template

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.

Prepare your MySQL Database and Rails app

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

rails_allinone_02.gif

 

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

rails_allinone_12.gif

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.

rails_allinone_13.gif

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.

rails_allinone_15.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_16.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_17.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_18.gif

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.

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

rails_allinone_19.gif

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

rails_allinone_23.gif

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.

rails_allinone_24.gif

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.

Step 6: Replace RightScripts in Cloned Server Template

Go back to Design -> Servers -> Server Templates and select the "Rails Clone" server template. 

rails_allinone_25.gif

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.

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

  • 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. Click the remove button rails_allinone_20.gif.

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

Congratulations!  You now have a custom server template 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:

  • APPLICATION (text) - Change the name to better describe your application.  (ex: My First Rails App on EC2)
  • APPLICATION_FILENAME (text) - Change the filename to match the name of your Rails application.  (ex: rails_app.gz)
  • DB_MYSQLDUMP_FILENAME (text)- Change the filename to match the name of your MySQL database. (ex: mysql_db.gz)
  • DB_SCHEMA_NAME (text)- Change the name so that it matches the schema of your database.  (ex: mysql_db)
  • 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!

Go back to Design -> Servers -> Server Templates.

rails_allinone_30.gif

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. 

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

 

Tag page
You must login to post a comment.