The RightScale server templates publish server images to launch. It is advisable to create your own server image because the cloud providers can remove their published images anytime. If you generate your own image, you control the lifecycle of those.
Create your own server image
- Use Packer to create a new server image.
- Install RightLink.
- On Windows
- Create a PowerShell script and save it as install-rightlink.ps1
$wc = New-Object System.Net.Webclient
Powershell -ExecutionPolicy Unrestricted -File rightlink.install.ps1
- Execute it from the Packer template
- For more information see “Create Custom Images with RightLink” at http://docs.rightscale.com/rl10/getting_started.html
- Make the image public, so RightScale can see it
- Open the AWS console
- On the EC2 Dashboard select AMIs
- Find the image by AMI resource ID
- On the Permission tab click the Edit button
- Keep the image private, but share it with the AWs account you create the server template in.
Attach the image to your RightScale server template
Make sure the image is visible in RightScale.
It can take 30 minutes for the new image to appear in the list.
- Open the RightScale Cloud Management console
- In the upper right corner select the account you want to work in,
- In the Clouds menu find the region where you created the image and click the Images link
- Search for the image
If you have an existing MultiCloud image and want to update the server image in it
- In the Design menu select the MultiCloud Images link
- Find the existing image by name
- Click the name of the image to open it
- On the Clouds tab select region, you are working in and click the pencil icon
- Click the Edit Image button
- Type a part of the name of the new server image you have just created to find it
- Click the name of the image to select it
- Click the Save button to add it to the MultiCloud image
- Click the Update button to save the MultiCloud image
Test the new MultiColud Image
Set the MultiCloud image version in the Server Template
Test the new MultiCloud image by TEMPORARILY using the HEAD revision of the Server Template and the MultiCloud image
To test the new image TEMPORARILY select the HEAD revision of the MultiCloud image to be used by the Server Template
- In the Design menu select the ServerTemplates link
- Find your Server Template
- Click the name of the template to open the info page
- Select the HEAD revision of the Server Template
- On the Images tab click the pencil to set the revision of the MultiCloud image to use
- TEMPORARILY select the HEAD revision for the MultiCloud Image and click the green check mark to save the selection.
In your CAT file set revision 0 to use the HEAD revision of the Server Template
Launch a new server using Self Service with the HEAD revision of the Server Template
Create the new version of the MultiCloud Image
When you have successfully tested the new MultiCloud Image create a new version of it.
- Find your MultiCloud Image in Desing, MultiCloud Images
- Click the Commit button and enter a description for the change
Create the new version of the Server Template
Save a new version of the Server Template
- Find your Server Template in Design, ServerTemplates
- Click the Commit button
Publish the Server Template
- Select the last revision and click the Publish to MultiCloud Marketplace button
- Keep it private
- Select the account group to share with and click the DESCRIPTIONS button
- Click the PREVIEW button
- Click the PUBLISH button
Import the Server Image to the other accounts you use
To be able to use the new version of the Server Image switch to the other accounts and import the template
- In the Design menu under MultiCloud Marketplace select the ServerTemplates link
- Enter a portion of the Server Template name in the Keyword box and click the GO button
- Click the name of the template
- Click the Import button
If you want to use a new MultiCloud image in the Server Template
To create a new MultiCloud image
Add the new MultiCloud image to the server template
- Open the RightScale Cloud Management console
- In the Design menu select ServerTemplates
- Find your server template
- On the Images tab click the Add MultiCloud Image button
When you launch an instance with RightScale Self Service, and the Chef cookbook execution fails, the instance goes into “stranded” mode. By default RightScale Self Service terminates the stranded instances, so there is no way to remote into them and read log files to find the cause of the problem.
To keep stranded instances running in RightScale
- Find the booting instance in Cloud Management and click the instance name,
- Click the lock icon on the top of the screen
RightScale Self Service cannot terminate locked instances. To terminate the instance after the troubleshooting process, unlock the instance and terminate the instance by hand.
When you need to upgrade an application on an AWS EC2 instance with minimum downtime, there are many options.
Upgrade an EC2 instance
- Stop the application, so users don’t make more changes,
- Create a backup of the database (snapshot of the RDS instance),
- Create a backup of the server (backup image of the EC2 instance),
- Upgrade the application on the server,
- Start the application,
- Test the new version of the application.
In case the upgrade fails, or the post-upgrade test fails
- Stop the application,
- If you use RightScale to launch servers:
- stop the RightLink service on the failed server to prevent RightScale auto terminating the restored server
(When RightScale finds a new identical server instance, it automatically shuts it down to avoid multiple instances with the same identifier.)
- Terminate the failed server
- Stop the failed server,
- Restore the database from the pre-upgrade backup with a new name,
- Restore the server instance from the pre-upgrade backup,
- Start the restored server,
- Change the database address in the application’s config file to point to the restored database,
- Start the application,
- Test the restored version of the application.
To make the backup image of the AWS EC2 instance
- Open the AWS console and navigate to EC2, Running instances
- Find the server instance you want to backup
- Right-click the row of the instance and select Image, Create Image
- Name the image and click the Create Image button
- Save the image Id from the popup
There are certain functions in RightScale scripts (RightScripts) that you cannot test without launching a new instance. To test your script:
- Edit the Head revision of the RightScale script and save it,
- Attach the Head revision of the RightScale script to the Head revision of the RightScale Server Template,
- Select the Head revision of the server template, on the Scripts tab click the Modify button
- Click the rev dropdown next to the script’s name and select head
- In your Self Service CAT file reference revision 0 (zero) of the Server Template (Head revision),
( “server_template_revision” => “0”, )
- Upload the Self Service CAT file to Self Service, but do not publish it,
- Launch a server instance from Self Service using the RightScale Self-Service Designer page, not the Catalog.
If the script has some errors, modify the Head revision of the RightScale script and launch a new server instance using the RightScale Self-Service Designer page.
When the script works perfectly:
- Commit the RightScale script, creating a new RightScale script revision,
- Attach the committed revision of the RightScale script to the Server Template’s Head revision,
- Commit the Server Template, creating a new Server Template revision,
- Publish the new revision of the Server Template,
- Reference the new revision of the Server Template in your Self Service CAT file.
When you use RightScale to launch servers in the cloud, you want to use the same base image to test your Chef cookbooks in Test Kitchen.
Packer by Hashicorp is a utility to create custom server images based on cloud images. You supply the image ID and other configuration parameters to create a new custom image.
To find the AMI ID of the base image of the RightScale Server Template
- Open the RightScale user interface in your browser,
- Select the RightScale account where the server template was created,
- In RightScale Cloud Management select Design / ServerTemplates,
- Select the server template,
- Select Images,
- Select the MultiCloud image,
- Select Clouds,
- Select the image in the region you are working in,
- The Resource UID is the AMI ID of the image.
In the previous parts of this tutorial we have launched instances (servers) in the cloud, but those were created by Test Kitchen, running on our workstation. Those instances are as good as they can be, but the cookbook did not reside on the Chef server.
To launch pre-production and production instances in the cloud, first we need to upload the cookbook to the Chef server. In Beginner’s Guide to DevOps Engineering part 4. Connect to the Chef server we have already connected our workstation to the Chef server.
Upload the cookbook to the Chef server
To make your cookbook available for all the servers of the organization we will upload the cookbook to the Chef server.
Launch the server in the Cloud
There are many ways to launch servers in a scripted way, we are going to review a few options. One is to use RightScale, a Cloud Management Platform, that can manage servers in multiple cloud environments.
Create a new Deployment
- Using your web browser log into the RightScale Cloud Management user interface,
- In the Manage menu select Deployment and click the New button,
- Enter the name of the new deployment,
- To add the new deployment to your bookmarks,
- On the left side in the Bookmarks section click the Add link,
- If necessary shorten the name of the bookmark and click OK,
- To reorder the bookmarks
- Click the Edit link and drag the bookmark to the desired position,
- Click the Done link to save your changes.
Create the CAT file
CAT files are Ruby like scripts that describe the configuration of the instance. It contain the name of the deployment the server should be placed it, the cloud attributes to assign security groups, regions, availability zones, set the drive size, specify security keys. The easiest way to configure a server is to copy an existing RightScale Self Service CAT file and update it with the new values.
If this is the first CAT file in your organization, get help from RightScale support and get a sample file from them.
If your organization already has a library of CAT files
- Make a copy of an existing CAT file
- Update the values to customize it for your server
- Application name
- Chef runlist
- Security group
- Deployment name
- Load balancer name
- Instance type
Upload the CAT file to RightScale
- Open the RightScale Self Service user interface,
- Select Designer on the left,
- Click the Upload CAT button and select the CAT file,
- Click the Upload button in the lower right corner,
- In the green popup in the upper right corner click the Publish to catalog link,
- In the lower right corner click the Yes, Publish button.
Launch the server in RightScale Self Service
- In the RightScale Self Service interface select Catalog on the left side,
- Select the catalog item you want to launch,
- Enter a name for the instance to be able to identify it later and select the instance in the dropdown list,
- Click the Launch CloudApp button.
To monitor the server launch
- In your web browser open the RightScale user interface,
- In the design menu select Deployments,
- Select the deployment of the instance,
- Click the instance to see in formation on it.
to the Tutorials page