In a previous post (here), by Cody De Arkland (@Codydeakland), he discussed how to get started using Cloud Assembly and Cloud-Init to build robust blueprints that can do just about anything!! In this post I am going to go through the process of creating an Ubuntu 16 or 18 template that will work smashingly with your Cloud Assembly subscription. So, let’s get started!!

 

Prerequisites:

  • A downloaded copy or Ubuntu 16 or 18…or both.
  • A working vSphere environment.
  • A subscription to VMware vRealize Automation Cloud.
  • About 25 minutes!!

 

Deploying the Ubuntu Image:

 

I am going to assume that you have deployed many an OS image via a provided ISO so I am not going to go step through that process. A couple suggestions, but not mandatory, when you go through the initial build for 16 and 18:

 

  • Try to use DHCP from the start. It will prevent you from having to change it to DHCP later (if, of course, you’re going to use DHCP which will make life easier)
  • Make sure to keep auto-updates off. It can cause issues down the road that are a pain to troubleshoot.

 

Configuring the Image:

 

The below steps are the important ones when creating a template that will work great with Cloud Assembly.

  1. After going through the initial install, log in through SSH (for easy copy and paste).
  2. If using Ubuntu 16 you will need to install cloud-init (Ubuntu 18 already comes with cloud-init. You can skip this step).
    1. Sudo apt -y install cloud-init
  3. Now that you have cloud-init install we need to configure the source so that it only uses the source we expect in vSphere.
    1. In terminal run <dpkg-reconfigure cloud-init>
    2. The following screen will come up:

Ensure that you only select OVF source for your template

  1. Now that you have configured cloud-init it’s time to clean up Ubuntu before you turn it into a template. As I normally try to operate, I don’t like to recreate the wheel so just use someone else’s cleanup script out on the internet. Below are two suggestions for scripts that I have used (again, just suggestions):
    1. For Ubuntu 16
    2. For Ubuntu 18
  2. After running the respective for your version of Ubuntu, you only have a couple more things to finalize the VM for a great template. Next you will need to clean cloud-init so it knows to run as next boot.
    1. Execute <sudo cloud-init clean>
  3. Finally, you need to clean the machine ID so that when the template is deployed it will know it’s a new build and you won’t get IP conflicts. To do this run the following three commands:
    1. sudo truncate -s 0 /etc/machine-id
    2. sudo rm /var/lib/dbus/machine-id
    3. sudo ln -s /etc/machine-id /var/lib/dbus/machine-id

 

THAT’S IT!!! You’re done. Shutdown the VM and convert it to a template.

 

Using the Content Catalog in Cloud Assembly

 

Cloud Assembly can use the content catalog as a source for templates as well as using templates that are stored on clusters associated to the vCenters you used for Cloud Accounts. Now that you have your template you can ‘Clone to Library’ to put the template into a content library.

 

 

Next, in Cloud Assembly, go to your vSphere Cloud account and click on the Sync Images button.

 

 

Finally, you can go into Image Mappings and select the template hosted on a cluster or from the Content Catalog.

 

 

You now have a an ubuntu template ready to be deployed via a Cloud Assembly blueprint and ready to be configured using Cloud Config.

 

 

In Closing….

 

Using the steps above you now have Ubuntu 16 and 18 templates that are ready to be used in Cloud Assembly with cloud-init. In a future post I will show how to create a CentOS template for Cloud Assembly.