3

I have a Terraform config that I want to use to create VMs from a Vsphere template (Redhat 7) but I need to be able to specify the network interface to apply the customizations (static IP, Subnet, Gateway, DNS).

provider "vsphere" {
  user           = "${var.vsphere_user}"
  password       = "${var.vsphere_password}"
  vsphere_server = "${var.vsphere_server}"
  allow_unverified_ssl = true
}

resource "vsphere_virtual_machine" "vm1" {

  name   = "vm1"
  folder = "${var.vsphere_folder}"
  vcpu   = 2
  memory = 32768
  datacenter = "dc1"
  cluster = "cluster1"
  skip_customization =  false

  disk {
    template = "${var.vsphere_folder}/${var.template_redhat}"
    datastore = "${var.template_datastore}"
    type = "thin"
  }

  network_interface {
    label = "${var.vlan}"
    ipv4_address = "10.1.1.1"
    ipv4_prefix_length = 16
    ipv4_gateway = "10.1.1.254"
  }

  dns_servers = ["10.1.1.254"]
  time_zone = "004"

}

I want to apply the static IP to bond0 instead of eth0, is this possible to do in Terraform?

Thanks.

brau
  • 93
  • 1
  • 8
  • Doesn't seem possible accoriding to the vsphere provider's documentation. Have you considered creating an issue with the vsphere provider or extending it? – SomeGuyOnAComputer Sep 18 '19 at 16:02

0 Answers0