I have the following variables file:
variable "vsphere_user" {
type = string
default = "terraform@mydomain.local"
}
variable "vsphere_password" {
type = string
description = "Terraform AD password"
}
variable "vm_template_name" {
type = string
description = "The template to clone to create the VM"
default = "ROCKY9"
}
variable "root_password" {
type = string
description = "Local linux root password"
}
variable vsphere_server {
type = string
description = "VMware Server DNS Name"
}
variable vsphere_datacenter {
type = string
description = "VMware Datacenter"
}
variable "vsphere_networks" {
type = map(string)
description = "A map of VM Networks for different NICs (e.g., nic1, nic2, nic3)"
}
variable vmware-hostnames {
type = map(string)
description = "List of VM Names"
}
variable datastores {
type = map(string)
description = "List of datastores"
}
variable vm_ips {
type = map(map(string))
description = "List of VM IPs"
}
variable vm-count {
description = "Number of VMs to create"
type = number
}
variable vsphere_resource_pool {
description = "VMware Resource Pool"
type = string
}
variable ipv4_netmasks {
description = "IPv4 Netmask"
type = map(number)
}
variable dns_server_list {
description = "DNS Server List"
type = list(string)
}
variable ipv4_gateway {
description = "IPv4 Gateway"
type = string
}
variable firmware {
description = "EFI or BIOS"
type = string
}
variable dns_domain {
description = "DNS Domain"
type = string
}
And this terraform file:
provider "vsphere" {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = var.vsphere_server
# Allow self signed certs
allow_unverified_ssl = true
}
data "vsphere_datacenter" "dc" {
name = var.vsphere_datacenter
}
data "vsphere_datastore" "datastore" {
name = var.datastores[0]
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "nic1" {
name = var.vsphere_networks["nic1"]
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "nic2" {
name = var.vsphere_networks["nic2"]
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "nic3" {
name = var.vsphere_networks["nic3"]
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_virtual_machine" "template" {
name = var.vm_template_name
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_resource_pool" "pool" {
name = var.vsphere_resource_pool
datacenter_id = data.vsphere_datacenter.dc.id
}
resource "vsphere_virtual_machine" "vm" {
count = var.vm-count
name = var.vmware-hostnames[count.index]
resource_pool_id = data.vsphere_resource_pool.pool.id
datastore_id = data.vsphere_datastore.datastore.id
wait_for_guest_net_timeout = 20
num_cpus = 4
memory = 4096
guest_id = "rockylinux_64Guest"
scsi_type = "pvscsi"
firmware = var.firmware
network_interface {
network_id = data.vsphere_network.nic1.id
adapter_type = "vmxnet3"
}
network_interface {
network_id = data.vsphere_network.nic2.id
adapter_type = "vmxnet3"
}
network_interface {
network_id = data.vsphere_network.nic3.id
adapter_type = "vmxnet3"
}
disk {
label = "disk0"
size = 40
eagerly_scrub = false
thin_provisioned = true
}
cdrom {
client_device = true
}
clone {
template_uuid = data.vsphere_virtual_machine.template.id
timeout = "180"
customize {
timeout = "180"
linux_options {
host_name = var.vmware-hostnames[count.index]
domain = var.dns_domain
}
network_interface {
ipv4_address = var.vm_ips[count.index]["nic1"]
ipv4_netmask = var.ipv4_netmasks["nic1"]
dns_server_list = var.dns_server_list
}
network_interface {
ipv4_address = var.vm_ips[count.index]["nic2"]
ipv4_netmask = var.ipv4_netmasks["nic2"]
}
network_interface {
ipv4_address = var.vm_ips[count.index]["nic3"]
ipv4_netmask = var.ipv4_netmasks["nic3"]
}
ipv4_gateway = var.ipv4_gateway
}
}
}
When I connect to the system and run nmtui I see duplicate connections:
ens256
VMware customization ens256
ens224
VMware customization ens224
ens192
VMware customization ens192
The two connections seem to be duplicate as far as I can tell. How can I avoid this? Is this a terraform vmware provider issue or a vmware tools issue or a vmware issue? I’ve never had this happen before.
Thanks
Brad