Deploying Windows Template with Terraform

Here is a new blog post based on the provided information:

When deploying a new Windows Server Core VM Template using Terraform, I encountered an issue with Guest Customizations timed out during the first plan execution. The same plan had worked previously with an existing Windows Template, so I was confused about what went wrong. Upon checking the console of the cloned VMs in vSphere, I found that it was stuck at the boot screen and unable to find the Operating System. This error message indicated that the disk was not able to boot into the templated disk.

After some research, I discovered that the issue was related to the VM Template being configured with EFI Firmware, which is now the default for vSphere 6.7 VMs. When Terraform deploys a new VM with BIOS Firmware, it causes the disk not to boot. The solution was to reconfigure the Template and make it default to BIOS. However, I found an easier option using the Terraform vSphere Provider.

The Terraform vSphere Provider was updated last year to include an option to set the Firmware on deployment. In the instance declaration file, we can set firmware as shown below:

resource “vsphere.virtual_machine” “example” {

firmware = “bios”

}

By setting firmware as a variable, we only have to configure the EFI or BIOS setting once in the terraform.tfvars file. In the variables.tf file, the variable is set with a default value of BIOS.

Once this was configured, the plan was able to successfully deploy the new Windows Template without issue, and Guest Customizations were able to continue. This solution not only resolved the booting issue but also eliminated the need for multiple configurations for EFI and BIOS settings.

Terraform Version: 0.11.7

Resources:

* https://github.com/terraform-providers/terraform-provider-vsphere/issues/441

*

*

Copyright © 2024 VIRTUALIZATION IS LIFE!. Powered by WordPress & Infinite Theme