AcloudA

Deploy a VMware VM from a template

Posted by Romain Serre on May 11, 2017
No ratings yet.

Most of the companies have to install guide to deploy servers with manual or automatic steps. These guides exist to get a consistent server installation across the organization. Thanks to a consistent environment, the management of the infrastructure is easier and the outages are less common.

Because a virtual machine is basically software, it’s easy to clone and redeploy. We can also create a template from a virtual machine and create new VMs from this template. In this way, we can customize the “initial VM” such as update the OS, copy scripts or set the system, make a template and deploy new VMs from this template. All new VMs will get the OS customization. All that remains to be done is to set the specific parameters of the OS such as IP address, computer name or specific scripts to run. So you can automate the VM deployment regarding your server specifications.

In this topic, we will see how to create a template from a VMware VM and how to deploy new from this template.

Environment

The screenshots have been taken from the following environment:

The VM I’ll deploy is a Windows Server 2016 Standard Core Edition. You can download an evaluation ISO from here.

Deploy the “initial VM”

First of all, I create a new VM in vCenter Server. Then I choose Create a new virtual machine.

New Virtual Machine - Select a creation type - Create a new VM

Next, specify the name of the virtual machine and choose a VM folder. I have created a folder called template where all my templates belong to.

New Virtual Machine - Edit Settings - Select a name and folder

In the next screen, choose the host or the cluster that will run the virtual machine.

New Virtual Machine - Edit Settings - Select a computer resource

Then choose the datastore where you want to store the virtual machine. In my example, I choose the vSAN datastore.

New Virtual Machine - Edit Settings - Select storage

Next, specify the compatibility of the virtual machine. I choose ESXi 6.5 because all my nodes run with this version. If you have older ESXi in your datacenter, choose an older compatibility version. Don’t forget that the future VMs will be deployed with the same settings than this one.

New Virtual Machine - Edit Settings - Select compatibility

Then choose the operating system you want to deploy. For this example, I deploy Windows Server 2016.

New Virtual Machine - Edit Settings - Select a guest OS

Next, configure the hardware as you wish. For example, I prepare the VM in DEV network and I configure CPU and Memory Hot Add. I verify also that the hard disk is deployed in thin provisioning. To finish I mount the Windows Server 2016 ISO.

New Virtual Machine - Edit Settings - Customize hardware - Virtual Hardware

In VM Options, I choose to lock the operating system when the last user is disconnected from the remote console and I set the boot option to UEFI (and secure boot).

New Virtual Machine - Edit Settings - Customize hardware - VM Options

To create the VM, just click on the finish in the last screen.

New Virtual Machine - Ready to complete summary

Operating System customization

Once the VM is created, just power on the VM and install the Windows Server you want. From my side, I have deployed Windows Serer 2016 Standard core edition. Once the OS is deployed, you can customize it. To make the first configuration I use sconfig:

Windows Serer 2016 Standard core edition Sconfig console

Thanks to this tool, you just have to type the number and make your configuration. You can, for example, set the Remote Desktop configuration or update the operating system.

Specify settings such as time zone, computer name, domain and so on will be removed when VMware will apply the customization. So, don’t apply settings on specialized configuration. Don’t forget also to install VMware tools.

Once the OS is upgraded, I can create folders, copy PowerShell scripts, binaries or/and configuration files. When you have finished customizing your operating system, just power off the server. Instead of sysprep the “initial VM” like with Hyper-V, VMware runs the customization after the new VM are deployed from the template. So, you can convert the VM into the template and revert back to VM to apply for example new patches.

Create the Template

Once you have finished your OS customization and the VM is powered off, you can convert the VM to a template. Before converting the VM to a template, I change the network to PROD:

Virtual Hardware configuration Network adapter

Next, I convert the VM to a VM template by right clicking on the VM and choosing Template | convert to Template.

VMware vSphere Web Client - Convert to Template navigator

Deploy the new VMware VM

To create a new VM from the template, right-click on the template and choose New VM from this template.

VMware vSphere Web Client - New Virtual Machine from Template

Specify the VM name and choose a folder where the VM belongs to.

Deploy From Template - Edit settings - Select a name and folder

Next, choose a host or a cluster where the VM will be hosted.

Deploy From Template - Edit settings - Select a computer resource

Then choose a datastore. From my side, I choose the vSAN datastore.

Deploy From Template - Edit settings - Select storage

In the next screen, I choose to customize the operating system and to power on the virtual machine after the creation.

Deploy From Template - Edit settings - Select clone options

Next, choose to create a customize guest OS specification.

Deploy From Template - Edit settings - Customize guest OS

First, give a customization spec name and a description. You can also choose if you want to use a sysprep answer file. I have written this topic about how to specialize a Windows Server guest OS (Hyper-V) and it explains how to create an answer file. For this example, I don’t use the answer file.

New VM Guest Customization Spec - Specify Properties

Next, specify registration information and click on next.

New VM Guest Customization Spec - Set Registration Information

In the next screen, I choose to use the virtual machine name for the OS computer name.

New VM Guest Customization Spec - Set Computer Name

Next, specify a valid license key.

New VM Guest Customization Spec - Enter Windows License

Then choose an administrator password and choose if you want to be logged automatically with the administrator account. It can be useful if you have scripts which require several reboots. However, be careful because the password will be written in clear in registry while the specified number of the reboot is not reached.

New VM Guest Customization Spec - Set Administrators Password

Next, choose the time zone you want.

New VM Guest Customization Spec - Time Zone

If you have scripts to run at the first login, you can enter the commands here. For example, you may want to deploy antivirus, System Center agents or other products. So, by scripts, you can run these deployments.

New VM Guest Customization Spec - Run Once

Then you can configure the network adapter(s) configuration. If you want manually configure the network adapters, you can select Manually select custom settings and click on “the pen” symbol.

New VM Guest Customization Spec - Configure Network

Choose if you want to DHCP or static IP address. You can also pick up an IP from a script or be prompted when the specification is used. I choose to set a static IP for this example.

New VM Guest Customization Spec - Configure Network - Edit Network IPv4

You can also specify the DNS server and the DNS suffixes.

New VM Guest Customization Spec - Configure Network - Edit Network DNS

Once you have finished setting the network configuration, you can choose to join a domain. Specify the domain name and the user which will be used to join the domain.

New VM Guest Customization Spec - Set Workgroup or Domain

The account chosen to join the domain must have permission on the default computer OU. The account must be allowed to create computer account object.

New VM Guest Customization Spec - Set Workgroup or Domain - Advanced Security Settings for Computers

To avoid issues in Active Directory, you have to generate a new SID for your new Operating System.

New VM Guest Customization Spec - Set Operation System Option

To finish with the guest customization spec, review what you have set and if all is correct, click on finish.

New VM Guest Customization Spec - Ready to complete

In the VM creation wizard, select the new VM guest optimization Spec and click on next. Then review the settings and click on finish to deploy the new VM.

Windows Server 2016 Standart Core Deploy from Template - Ready to complete

The VM will be automatically powered on. The OS is started but at this step, the customization is not applied. Wait a few minutes and the server should reboot automatically. Then this message will appear:

MyVM VMware Remote Console customization is in progress

At this moment, the VM customization is applied and so the server is renamed, the IP configuration is applied and the server joins the domain.

MyVM VMware Remote Console Getting ready view

Once the server is ready, you should have all information in vCenter like in the below screenshot.

VMWare vSphere Web Client - MyVM - Summary

At this step, your VM is ready.

Revert back from template to a VM

You can convert a template to a virtual machine. To run this process, just right click on the template and choose Convert to Virtual Machine.

VMWare vSphere Web Client - Template convert to Virtual Machine

Next, choose a host or a cluster where the VM will be hosted.

Windows server 2016 Standart Core Convert Template to Virtual Machine - Edit settings - Select a compute resource

Review the settings and click on finish to convert the template to a VM.

Windows server 2016 Standart Core Convert Template to Virtual Machine - Ready to complete

When the process is finished, you have again a virtual machine instead of a template.

VMWare vSphere Web Client - Template summary

Related materials:

Views All Time
3
Views Today
23
Return to all posts

5 SCCM Tools Every Sysadmin Should Know
Big Data and Machine Learning: Introducing Cortana Intelligence Solution Templates to Accelerate Adoption

Please rate this

The following two tabs change content below.

3 Responses to “Deploy a VMware VM from a template”

  1. […] that my VM is running on Azure, I’ll join him to my […]

  2. […] restoring a VM from a replica, we’ll see this picture […]

  3. […] The platform can be deployed in the shortest time and with the help of the built-in wizard and templates, it is able to create new virtual machines in a matter of […]

Leave a Reply

You must be logged in to post a comment.