Perform guest customization on a Virtual Machine

Cloud-init

Cloud-init is a utility that is used to customize Linux VMs during first-boot initialization. The utility must be pre-installed in the operating system image used to create VMs. Cloud-init runs early in the boot process and configures the operating system on the basis of data that you provide (user data). You can use Cloud-init to automate tasks such as setting a host name and locale, creating users and groups, generating and adding SSH keys so that users can log in, installing packages, copying files, and bootstrapping other configuration management tools such as Chef, Puppet, and Salt. For more information about Cloud-init, see https://cloudinit.readthedocs.org/.

Sysprep

Sysprep is a utility that prepares a Windows installation for duplication (imaging) across multiple systems. Sysprep is most often used to generalize a Windows installation. During generalization, Sysprep removes system-specific information and settings such as the security identifier (SID) and leaves installed applications untouched. You can capture an image of the generalized installation and use the image with an answer file to customize the installation of Windows on other systems. The answer file contains the information that Sysprep needs to complete an unattended installation.

To customize a Linux VM by using Cloud-init, do the following:

  1. Log in to the web console by using the Nutanix credentials.
  2. In the VM dashboard (see VM Dashboard), do one of the following:
    1. To create a VM, click Create VM.
    2. To clone a VM, click the VM that you want to clone, and then click Clone.
  3. In the Create VM or Clone VM dialog box, specify a name for the VM and allocate resources such as vCPUs, memory, and storage. Select the Custom Script check box and specify how you want to customize the VM.

For information about creating a VM and specifying customization options, see Creating a VM (AHV). For information about cloning a VM, see Managing a VM (AHV).

  • In the VM dashboard, select the VM, and then click Power On. The VM is powered on and initialized based on the directives in the user data file. To create a reference image from the VM, use Image Service. See Image Service in the VM Management chapter of the Acropolis App Mobility Fabric Guide.

CloudInit must be installed on Linux VM

Input Formatting

Begin with #!

#!/bin/bash
touch /tmp/fooTest
mkdir /tmp/barFolder

#include
http://s3.amazonaws.com/path/to/script/1
http://s3.amazonaws.com/path/to/script/2

#cloud-config

# Set hostname
hostname: foobar

# Add user(s) users:
– name: nutanix
sudo: [‘ALL=(ALL) NOPASSWD:ALL’]
ssh-authorized-keys:
– ssh-rsa: <PUB KEY>
lock-passwd: false
passwd: <PASSWORD>

# Automatically update all of the packages
package_upgrade: true
package_reboot_if_required: true

# Install the LAMP stack packages:
– httpd
– mariadb-server
– php
– php-pear
– php-mysql

# Run Commands after execution runcmd:
– systemctl enable httpd

To customize a Windows VM by using Sysprep, you need to perform the following tasks:

  • Create a reference image by using Sysprep.
  • Create a VM from the reference image.
  • You can also customize a VM when performing a fresh installation of Windows with an ISO file.

The Customization Process in a Nutanix Cluster: You can use Cloud-init or Sysprep both when creating and when cloning VMs in a Nutanix cluster. For unattended provisioning, you can specify a user data file for Cloud-init and an answer file for Sysprep. All Cloud-init user-data formats are supported. For example, you can use the Cloud Config format, which is written in YAML, or you can provide a multi-part archive. To enable Cloud-init or Sysprep to access the script, AOS creates a temporary ISO image that includes the script and attaches the ISO image to the VM when you power on the VM.

Note: The ISO image is mounted on bus IDE 3, so ensure that no other device is mounted on that bus.

You can also specify source paths to the files or directories that you want to copy to the VM, and you can specify the target directories for those files. This is particularly useful if you need to copy software that is needed at start time, such as software libraries and device drivers. For Linux VMs, AOS can copy files to the VM. For Windows VMs, AOS can copy files to the ISO image that it creates for the answer file.

After customizing a VM, you can copy the VDisk of the VM to Image Service for backup and duplication.

Leave a Reply

Your email address will not be published. Required fields are marked *