Skip to content

Basics of Instance Automation

March 5, 2012

Automation is a huge piece of any successful cloud deployment. When you have the ability to scale horizontally with seemingly “infinite” resources you need a quick and automatic method of setting up additional services. Infrastructure-as-a-Service cloud services, such as Amazon EC2 or Eucalyptus, have built-in functionality that allows for information to be passed to new instances and allows for complete system automation.

The two main technologies that assist the cloud user or cloud developer with an automation task are the following:

  • Metadata service
  • Automated user data execution

The metadata service allows the user to supply an instance with information regarding it’s setup, environment, and data provided by the user through the cloud service (For more information see Amazon EC2 Instance Metadata or Eucalyptus Metadata Service). This ability to pass data to a new instance gives the user a simple method for automating the instance’s setup without needing to ever login to the instance. The user’s data, kept at http://169.254.169.254/latest/user-data by the metadata service, can contain a script that, with the proper setup on the instance’s image, can be executed automatically as the instance boots.

To achieve automatic execution of the user data from the metadata service, we can utilize a couple different methods. The first method involves running commands inside of the /etc/rc.local file of an instance’s image. The most basic version of an /etc/rc.local that will automate the execution of user data is the following:

curl -s -o /tmp/user-data http://169.254.169.254/latest/user-data 
sh /tmp/user-data

In the above code snippet, we first download the user data from the metadata service at http://169.254.169.254/latest/user-data and place it into a temporary file. Then we execute the user data using a basic POSIX shell. This is only the most basic form. You can find a more sophisticated /etc/rc.local implementation in the Eucalyptus Starter Images.

An emerging standard method for downloading and utilizing the user data is with CloudInit. CloudInit takes the above /etc/rc.local functionality and extends it greatly. It is definitely worth it to research CloudInit’s features and use it with a Debian or Ubuntu based image and hopefully in the near future Fedora and Centos as well.

This was simple a basic primer on how the metadata service of an IaaS cloud service functions behind what the cloud user will see. In my next post, I’ll show how to use the metadata service to do some basic instance setup automation.

Advertisements
One Comment
  1. hspencer77 permalink

    Reblogged this on More Mind Spew-age from Harold Spencer Jr. and commented:
    More IaaS goodies from Eucalyptus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: