Cannot provision windows 2019/2022 server to vShere

I am having issues provisioning windows servers to vmware using terraform. i have created a template from a widows server image and can creat new vms from it in vcenter with no issues.

below terrafom erroer and te accompanig config files. ThnX for any pointers in advace.

Terraform Error message
vsphere_virtual_machine.vm: Creating…
vsphere_virtual_machine.vm: Still creating… [10s elapsed]
vsphere_virtual_machine.vm: Still creating… [20s elapsed]
vsphere_virtual_machine.vm: Still creating… [30s elapsed]
vsphere_virtual_machine.vm: Still creating… [40s elapsed]
vsphere_virtual_machine.vm: Still creating… [50s elapsed]
vsphere_virtual_machine.vm: Still creating… [1m0s elapsed]
vsphere_virtual_machine.vm: Still creating… [1m10s elapsed]

│ Error: error sending customization spec: Customization of the guest operating system is not supported due to the given reason:

│ with vsphere_virtual_machine.vm,
│ on vsphere.tf line 52, in resource “vsphere_virtual_machine” “vm”:
│ 52: resource “vsphere_virtual_machine” “vm” {

Varables.tf

#====================#

vCenter connection

#====================#
variable “vsphere_user” { description = “” }
variable “vsphere_password” { description = “” }
variable “vsphere_vcenter” { description = “” }
variable “vsphere_unverified_ssl” { description = “” }
variable “vsphere_datacenter” { description = “” }
variable “vsphere_cluster” { description = “” }

#=========================#

vSphere virtual machine

#=========================#
variable “vm_boot” { description = “” }
variable “vm_datastore” { description = “” }
variable “vm_network” { description = “” }
variable “vm_template” { description = “” }
variable “vm_linked_clone” { description = “” }
variable “vm_ip” { description = “” }
variable “vm_netmask” { description = “” }
variable “vm_gateway” { description = “” }
variable “vm_dns” { description = “” }
variable “vm_domain” { description = “” }
variable “vm_cpu” { description = “” }
variable “vm_ram” { description = “” }
variable “vm_name” { description = “” }

terraform.tfvars
vsphere_vcenter = “esxi4.bjomain.com
vsphere_user = “administrator@vsphere.local”
vsphere_password = “password”
vsphere_unverified_ssl = “true”
vsphere_datacenter = “My Data Center”
vsphere_cluster = “bjomain”

vm_boot = “efi”
vm_name = “win2019-prod”
vm_template = “win2019-template”
vm_datastore = “datastore_hdd”
vm_network = “VM Network”
vm_netmask = “24”
vm_gateway = “172.10.11.254”
vm_dns = “172.10.11.254”
vm_domain = “bjomain.com
vm_linked_clone = “false”
vm_cpu = “4”
vm_ram = “32000”
vm_ip = “172.10.11.97”

vshere.tf

#===============================================================================

vSphere Provider

#===============================================================================

provider “vsphere” {
#version = “1.11.0”
vsphere_server = “{var.vsphere_vcenter}" user = "{var.vsphere_user}”
password = “${var.vsphere_password}”

allow_unverified_ssl = “${var.vsphere_unverified_ssl}”
}

data “vsphere_datacenter” “dc” {
name = “${var.vsphere_datacenter}”
}

data “vsphere_compute_cluster” “cluster” {
name = “{var.vsphere_cluster}" datacenter_id = "{data.vsphere_datacenter.dc.id}”
}

data “vsphere_datastore” “datastore” {
name = “{var.vm_datastore}" datacenter_id = "{data.vsphere_datacenter.dc.id}”
}

data “vsphere_network” “network” {
name = “{var.vm_network}" datacenter_id = "{data.vsphere_datacenter.dc.id}”
}

data “vsphere_virtual_machine” “template” {
name = “{var.vm_template}" datacenter_id = "{data.vsphere_datacenter.dc.id}”
}

resource “vsphere_virtual_machine” “vm” {
name = “{var.vm_name}.{var.vm_domain}”
resource_pool_id = “{data.vsphere_compute_cluster.cluster.resource_pool_id}" datastore_id = "{data.vsphere_datastore.datastore.id}”

num_cpus = “{var.vm_cpu}" memory = "{var.vm_ram}”
guest_id = “{data.vsphere_virtual_machine.template.guest_id}" firmware = "{var.vm_boot}”

network_interface {
network_id = “{data.vsphere_network.network.id}" adapter_type = "{data.vsphere_virtual_machine.template.network_interface_types[0]}”
}

disk {
label = “{var.vm_name}.{var.vm_domain}.vmdk”
size = “{data.vsphere_virtual_machine.template.disks.0.size}" eagerly_scrub = "{data.vsphere_virtual_machine.template.disks.0.eagerly_scrub}”
thin_provisioned = “${data.vsphere_virtual_machine.template.disks.0.thin_provisioned}”
}

clone {
template_uuid = “{data.vsphere_virtual_machine.template.id}" linked_clone = "{var.vm_linked_clone}”

customize {
  timeout = "20"

  windows_options {
    computer_name = "${var.vm_name}"
    #domain    = "${var.vm_domain}"
  }

  network_interface { }
}

}
}

Seems like a vSphere API error
Maybe you need to install VMware Tools on your image.

ThnX it now boots but into an undefined config state which cannot be repaired. Gives me a new direction to explore though so if there are more ideas I’ll try that.

I managed to resolve` this issue for Windows 2022 by installing both vmware tools and all security patches and then creating the vshere template. all good now.

BTW: I am on vmware 8 already.

1 Like