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.
- After going through the initial install, log in through SSH (for easy copy and paste).
- If using Ubuntu 16 you will need to install cloud-init (Ubuntu 18 already comes with cloud-init. You can skip this step).
- Sudo apt -y install cloud-init
- Now that you have cloud-init install we need to configure the source so that it only uses the source we expect in vSphere.
- In terminal run <dpkg-reconfigure cloud-init>
- The following screen will come up:
Ensure that you only select OVF source for your template
- 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):
- 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.
- Execute <sudo cloud-init clean>
- 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:
- sudo truncate -s 0 /etc/machine-id
- sudo rm /var/lib/dbus/machine-id
- 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.