posted

0 Comments

By: Paco Gómez

This is a repost from Paco Gómez’s personal blog.

For those minimalist DevOps engineers out there, this post describes how to provision a virtual machine on VMware vCloud® Air™ the quickest way possible. The steps include adding a public SSH key and configuring the network to make the machine SSH-Ready.

On my previous post, I described how to provision CoreOS on vCloud Air. CoreOS instances get customized through cloud-config. A user can define the IP of the machine and add the public SSH key by including all that information in a text file included in a virtual ISO mounted on the VM.

In this post I will provision an Ubuntu VM and customize it with the VMware Guest OS Customization method. The process is done in 3 simple steps:

  1. Create a VM from an Ubuntu template available in the catalog. Take note of the IP assigned.
  2. Upload the public SSH key as part of the customization script to add it to the ubuntu user. Start the machine and perform the customization.
  3. Create the NAT rule to allow SSH traffic to the machine.

Now the machine will be ready. Simply SSH into and start using it.

I will make some assumptions, like having a vCloud® Air™ OnDemand account (Subscription or vCA-N also applies), that a virtual data center has already been created, that vca-cli is already installed on your local computer and that at least one public IP address has been allocated.

Let’s get started. Let’s log in and inspect the virtual data center and catalog:

Now let’s create the VM and see what IP address has been assigned by vCA:

The IP assigned is ‘192.168.109.4’.

It is possible to script the retrieval of the IP. vca-cli has the option to print out tables in JSON format (-j or –json). We can use jq to get the IP and save it in a variable to use it in the future:

A customization script is a regular shell script that is added to the VM properties and then executed by the VMware tools running on the Guest OS when the operation start VM and force customization is performed. I have created a simple customization script that adds the SSH public key to the authorized_keys file of the ubuntu user account. We can use vca-cli to upload the script and perform the customization:

As a final step, let’s configure the NAT rule to allow to SSH into the machine:

If you haven’t already, configure a general SNAT rule and disable the firewall:

And that’s all. Now SSH into the new VM using the private SSH key:

Cool!

You might want to configure a couple of things. Set the DNS settings:

And upgrade to the latest release (14.04):

After the upgrade is finished, you can save the virtual machine as a template in the catalog. The next VMs can be created from the new template instead of the public catalog template and save extra pre-configuration efforts. But that will be the topic of a future blog entry.

Summary

vCloud Air OnDemand users can provision SSH-ready machines in just a few simple vca-cli commands. The process described here can also be used to initialize the VMs with other customization scripts and bootstrap an entire custom environment in just a few minutes.

For more information about vCloud Air, visit vcloud.vmware.com.

Be sure to subscribe to the the vCloud blog with your favorite RSS reader, or follow our social channels at @vCloudand Facebook.com/VMwarevCloud for the latest updates.