Skip to main content

Blueprint customization using cloudConfig

In this post we will see how to prepare our environment for blueprint customization using cloudConfig. Let's start with an understanding of cloudconfig and cloud-init and then we will jump into the preparation. Basically customization include running commands after deployment, creating and editing configuration files, creating user account and installing application software.


You can use cloudConfig and cloud-init to customize a blueprint in vRealize Automation 8.x so that it can be deployed and run on any cloud. You can combine YAML code with cloudConfig to customize a blueprint so that different commands run on different cloud deployments.


  • cloud-init is an industry standard software package that allows customization.
  • cloudConfig is the VMware YAML blueprint code that sends instruction to cloud-init.

Okay, as part of preparation you should be aware of few things

Cloud configuration scripts are supported in image mapping and blueprint code
  • You can add cloudConfig scripts to an image mapping
  • These commands should be noninteractive. Inputs are not allowed
  • If you have cloudConfig commands in both an image mapping and a blueprint, the commands are combined into a single list of commands
  • If a conflict occurs between the cloudConfig command in an image mapping and the cloudConfig commands in a blueprint, the directives in the image mapping take precedence.

Restrictions in vSphere

  • The VM that is deployed must have a DHCP IP address. Static IP address are not allowed
  • You can apply machine initialization in vRealize Automation Cloud Assembly through vSphere customization specifications, or by running commands directly so do not combine a vSphere customization specification with a YAML blueprint that uses cloudConfig

Step 1: Create a vSphere VM template that support cloud-init


You can either use CentOS or Ubuntu templates

CentOS Template

1. Install the cloud-init software in CentOS.
yum install -y cloud-init
cloud-init is already installed in Ubuntu version 18 but it must be installed in CentOS.
2. Install Perl in CentOS.
yum install -y perl
CentOS requires the Perl library. Perl is already installed on Ubuntu.
3. Use either Nano or vi to create the /etc/cloud/cloud.cfg.d/99-customnetworking.cfg file.
4. Add a line to the 99-custom-networking.cfg file.
network: {config: disabled}
Creating the 99-custom-networking.cfg file with this setting takes network control away from cloud-init.
5. Save the 99-custom-networking.cfg file.
6. Clean the virtual machine to use it as a cloud-init template.
# cloud-init clean

IMPORTANT
After you run cloud-init clean, you must not do anything else in the template.
7. Close the console and shut down the guest operating system from the vSphere Client.
8. Edit the settings of the Centos-Cloud-Init-Ready virtual machine.
9. Expand the CD/DVD drive.
10. Select Passthrough CD-ROM from the Device Mode drop-down menu

IMPORTANT
This step is critical. Even if all the other prerequisites are installed into the template, the template does not work with cloud-init if the CD-ROM is not set to Passthrough mode. cloud-init commands are sent to the virtual machine through the CD-ROM.
11. Convert the virtual machine to a template

Ubuntu Template

In Ubuntu 18, cloud-init is already installed.
1. If Ubuntu 18 is not used, run apt-get install cloud-init.
2. Enter dpkg-reconfigure cloud-init.
3. On the Package configuration menu for cloud-init, deselect all options except OVF and tab to OK.
4.Enter echo "localhost" > /etc/hostname.
This command sets the host name to localhost.
5. Follow step6 to11 from CentOS template preparation

Step 2: Customize hostname in a VM after deployment by using cloudConfig


The cloudConfig: section must line up under other parts of machine properties(image, flavor, network and so on)

Create a blueprint as below
You are passing the Linux hostnamectl command directly to the virtual machine. This command is run once during the cloud-init configuration.
The parameter that the hostnamectl command uses in the set-hostname operation is the value of the hostname1 variable.


cloudConfig Logs and Scripts in a deployed machine



Log location    
 Log Purpose
 /var/log/cloud-init-output.log Output log file
 /var/log/cloud-init.log
 Main log file
 /var/lib/cloud/isntance/scripts Main cloudConfig scripts directory
 /var/lib/cloud/instance/user-data.txt Main cloudConfig scripts
 /var/lib/cloud/isntance/scripts/runcmd Runcmd script file







Comments

Popular posts from this blog

Deleting stale kubernetes clusters in vCD

Unlike the previous version the CSE 4.x is a stateless appliance and its data is stored in VMware Cloud Director Database.  The cluster creation and deletion compared with CSE 3.x version has improved. Besides, there are some scenarios where the cluster deletion is failing even when the "Force Delete" option is chosen. We can use vCD API explorer to delete it, the following are the API queries you can execute  Under definedEntity POST /1.0.0/entities/{id}/resolve DELETE /1.0.0/entities/{id}

Manage RabbitMQ using VCP LCM

I have been working in vCD for quite some time, and most of the implementation engineers or consultants faced issues during the deployment or upgrade of RabbitMQ for the vCD message queuing service. From vCD 10.2.2, we can use the built-in MQTT client instead of RabbitMQ however, for VCD multisite configuration or some 3rd party applications need RabbitMQ, such as Veeam or VMware HCX. Using the VCP LCM, we can create a new RabbitMQ environment or manage an existing environment. The reason for this blog is that none of the VMware documentation has the information that registering an existing RMQ instance is only going to work if the RMQ instance was previously deployed by the VCP LCM (or at least, if it is a similar setup based on a Bitnami RMQ VM). Other RMQ instances (e.g., running in CentOS) are not supported and cannot be imported into the VCP LCM 1.5. I hope this information will be useful for someone who is performing green field deployment or upgrading an existing setup.