vsphere provider - vsphere_virtual_machine resource - arguments not configured in vSphere 5.5 VM

170 views
Skip to first unread message

Chad Kellerman

unread,
Jul 7, 2016, 1:28:03 PM7/7/16
to Terraform
Hey All.....

     I am trying to deploy a couple Virtual Machines in vSphere 5.5 via Terraform (0.6.16) but the configurations I provide in my main.tf file are not being configured in the Virtual Machine but vSphere.

I create a Red Hat 7.2 image and publish it to vSphere via Packer. ( rhel-7.2-x86_64-automation-base/rhel-7.2-x86_64-automation-base.vmdk below)

Then I use that vmdk to deploy application specific vm's in a folder.  But, the deployed VM's do not contain the dns_suffixes, dns_servers, and network_interface parameters.

Can anyone point me in the right direction as to why these arguments are not being configured?


---------------------<main.tf>-----------------------------------------
# --- Configure the VMware vSphere Provider
provider "vsphere" {
  user                 = "${var.vsphere_user}"
  password             = "${var.vsphere_password}"
  vsphere_server       = "${var.vsphere_server}"
  allow_unverified_ssl = "true"
}

# --- Create the folder for the application vm's
resource "vsphere_folder" "application" {
  datacenter = "${var.datacenter}"
  path = "NON-Production/java-opc/spring-boot-jpetstore-test-app"
}

# --- create the vm's
resource "vsphere_virtual_machine" "appserver1" {
  name   = "spring-boot-jpetstore-app1"
  folder = "${vsphere_folder.application.path}"
  vcpu   = 1
  memory = 2048
  datacenter = "${var.datacenter}"
  cluster = "${var.cluster}"
  dns_suffixes = ["domain.com","vsphere.domain.com"]
  dns_servers = ["10.50.1.250","172.22.4.55","172.22.4.56"]

  custom_configuration_parameters{
      "tools.syncTime" = "TRUE"
      "virtualHW.version" = "10"
      "virtualHW.productCompatibility" = "hosted"
      "ethernet0.pcislotnumber" =  "33"
  }

  network_interface {
      label = "10_68_6_VMNet"
      ipv4_address = "10.68.6.27"
      ipv4_prefix_length = "24"
      ipv4_gateway = "10.68.6.1"
  }

  disk {
    datastore = "${var.datastore}"
    vmdk = "rhel-7.2-x86_64-automation-base/rhel-7.2-x86_64-automation-base.vmdk"
    bootable = "true"
  }
}



open-vm-tools are installed on the red hat vmdk.  But I don't understand why the network configs aren't applied.

Any help or direction would be greatly appreciated.

Thanks,
Chad


Chad Kellerman

unread,
Jul 8, 2016, 3:42:30 PM7/8/16
to Terraform
If anyone is keeping score at home....


The configurations I mentioned that were not being applied to the deployed virtual machine in vsphere ( dns_suffixes, dns_servers, network_interface configurations) do not appear to be available when the vmdk configuration is used in disk.  It only appears to work with the template configuration.


    so this works:

    disk {
    datastore = "${var.datastore}"
    #vmdk = "rhel-7.2-x86_64-automation-base/rhel-7.2-x86_64-automation-base.vmdk"
    template = "NON-Production/java-opc/images/rhel-7.2-x86_64-automation-base"
    bootable = "true"
  }

Thanks,
Chad
Reply all
Reply to author
Forward
0 new messages