Terraform vsphere network interface interface configuration

I have a Terraform config that I want to use to create virtual machines from a Vsphere template (Redhat 7), but I need to specify the network interface to apply the settings (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 static IP to bond0 instead of eth0, is it possible to do this in Terraform?

Thank.

+3


source to share





All Articles