I have been pulling what little hair I have left trying to solve this. It seems that whenever I add anything in the “customize” block, I get the error above. I am using a CentOS 7.8 template that has been sanitized. Every time I add the customize block, it errors out. I haven’t been able to progress past “terraform plan”. If you have seen this, please let me know. If I take the block out, I can get past the planning phase.
I am using the vSphere provider and trying to create multiple VMs (3 for now) using “count”. I don’t know if that has anything to do with this problem.
main.tf:
# Get the ID of the network to join
data "vsphere_network" "network" {
name = var.network_name
datacenter_id = data.vsphere_datacenter.dc.id
}
# Get the ID of the virtual machine template
data "vsphere_virtual_machine" "template" {
name = var.template_name
datacenter_id = data.vsphere_datacenter.dc.id
}
# Create X number of VMs
resource "vsphere_virtual_machine" "vm" {
count = var.vm_count
name = "${var.vm_name}-${count.index}"
folder = var.vm_folder
resource_pool_id = data.vsphere_resource_pool.pool.id
datastore_id = data.vsphere_datastore.datastore.id
num_cpus = data.vsphere_virtual_machine.template.num_cpus
memory = data.vsphere_virtual_machine.template.memory
guest_id = data.vsphere_virtual_machine.template.guest_id
disk {
label = "disk0"
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
}
network_interface {
network_id = data.vsphere_network.network.id
}
clone {
template_uuid = data.vsphere_virtual_machine.template.id
customize {
linux_options {
host_name = format("%s-%d", var.vm_name, count.index)
domain = "mydomain.net"
}
}
}
}
terraform.tfvars:
vsphere_user = "administrator@vsphere.local"
vsphere_password = "password"
vsphere_server= "vcenter.mycompany.net"
dc_name = "mydc"
cluster_name = "mycluster"
resource_pool_name = "myclusterI/Resources"
datastore_name = "myds"
network_name = "vlan22"
template_name = "centos7.8-tmpl"
vm_name = "demo"
vm_count = 3
vm_folder = "Sandbox/junk"
vm_cpus = 2
vm_memory = 4096
vm_network_ip = "10.10.10"
vm_start_ip = 10
vm_gateway_ip = 1