Proper format for adding NIC to host during cloning?

Hi everyone,

I was directed here from the Github project for Terraform-provider-vsphere.

I’m instantiating a host, and that’s so-far, so-good, but I’m now wanting to add a second nic to SOME of the VMs cloned off that golden image.

I’ve tried adding a secondary network_interface statement to the vsphere_virtual_machine record, or to the customization{} and clone{} inside, or both, and in all cases I’m met with a familiar-to-you-I-hope message:

Error: error sending customization spec: The number of network adapter settings in the customization specification: 1 does not match the number of network adapters present in the virtual machine: 2.

The spec should be no surprise, once we agree I cut out some looping that wasn’t working, and let me know if I should post it in all its anonymized verbose glory:

resource "vsphere_virtual_machine" "prdsplidx-02" {
:
  network_interface {
    network_id = data.vsphere_network.DMZ.id
  }

  network_interface {
    network_id = data.vsphere_network.priv.id
  }
:

  clone {

    template_uuid = data.vsphere_virtual_machine.template_prod.id
    linked_clone  = var.linked_clone

    customize {
      linux_options {
        host_name = "prdsplidx02"
      }

      network_interface {
        ipv4_address = split("/",var.prdsplidxmap["prdsplidx02"].ips[0])[0]
        ipv4_netmask = split("/",var.prdsplidxmap["prdsplidx02"].ips[0])[1]
      }

      network_interface {
        ipv4_address = split("/",var.prdsplidxmap["prdsplidx02"].ips[1])[0]
        ipv4_netmask = split("/",var.prdsplidxmap["prdsplidx02"].ips[1])[1]
      }

      ipv4_gateway = cidrhost(var.prdsplidxmap["prdsplidx02"].ips[0], -2)
      dns_server_list = ["10.1.2.3"]
      dns_suffix_list = ["nettymcnetface.net"]
    }
  }

My clone source has one nic.

The setup achieves instantiation when it’s just one nic mentioned above and below, but no combo yet seems to allow for an additional nic.

I’m forgetting something obvious, aren’t I? Flame gently, and I appreciate any help.

  • bish