How to customize virtual machine using Cloud-init metadata and user data
search cancel

How to customize virtual machine using Cloud-init metadata and user data

book

Article ID: 311895

calendar_today

Updated On:

Products

VMware vSphere ESXi VMware Telco Cloud Platform VMware vCenter Server

Issue/Introduction

This article provides information on how to customize virtual machine using Cloud-init metadata and user data in vSphere 7.0 u3.

Environment

VMware vSphere ESXi: 7.0 U3x

VMware vCenterserver : 7.0 U3x

Telco cloud platform: 5.0

Resolution

Prerequisites:

  1. Ensure that the vSphere version is 7.0 Update 3 or later.
  2. Ensure that VMware Tools version 11.3.0 or later is installed in the guest operating system
  3. Ensure that cloud-init version 21.1 or later is installed.
  4. Ensure that Datasource OVF (cloud-init ver < 23.1)or Datasource VMware(cloud-init ver >= 23.1)is included in cloud-init Datasource search list.

Notes:

  1. Virtual machine customizaion using Cloud-init metadata and user data is supported by the vSphere Web Services API (See vSphere Web Services SDK Programming Guide 7.0 ) and the vSphere Automation API (See vSphere Automation API Reference ), there is no UI support for now.
  2. Cloud-init metadata is a mandatory field in customization specification. Furthermore:
    1. The length of metadata cannot be greater than 512 * 1024 characters.
    2. The network config in metadata can be either version 1 or version 2. Please refer to https://cloudinit.readthedocs.io/en/latest/topics/network-config.html for details.
    3. Metadata can be in JSON or YAML format.
    4. Metadata sample in JSON format:
      			{
      				"instance-id": "cloud-vm",
      				"local-hostname": "cloud-vm",
      				"network": {
      					"version":2,
      					"ethernets": {
      						"nics": {
      							"match": {
      								"name": "ens*"
      							},
      							"dhcp4": "yes"
      						}
      					}
      				}
      			}
    5. Metadata sample in YAML format:
      			instance-id: cloud-vm
      			local-hostname: cloud-vm
      			network:
      				version: 2
      				ethernets:
      					nics:
      						match:
      							name: ens*
      						dhcp4: yes
  3. Cloud-init user data is an optional field in customization specification, for details please refer to the Cloud-init document for user data format: https://cloudinit.readthedocs.io/en/latest/topics/format.html
    1. The length of user data cannot be greater than 512 * 1024 characters.
    2. User data example in the Cloud-init document https://cloudinit.readthedocs.io/en/latest/topics/examples.html

Further notes

  1. If you want to disable cloud-init‘s network configuration capability and rely on other methods, please disable it as in below in metadata:
    			network:
    				config: disabled
  2. If network config is absent, cloud-init will generate a fallback network which is usually DHCP.
  3. The instance ID in metadata must be unique for each customization using this feature. If you want to re-customize a virtual machine using this feature, please make sure a different instance-id is specified in metadata.

Additional Information

Achieve Speed, Scale, and Reliability of Virtual Machine Deployments with ‘cloud-init’

Customizing Guest OS using Cloud-Init