Terraform: Terraform 0.9.x vsphere: arguments applied wrong

Created on 13 Apr 2017  ยท  4Comments  ยท  Source: hashicorp/terraform

Terraform 0.9.x vsphere_* seems to ignore, or wrongfully apply certain arguments, while plan shows expected output.

Terraform Version

0.9.1/0.9.2/0.9.3

Affected Resource(s)

  • vsphere_virtual_machine, probably all vsphere_*

Terraform Configuration Files

variable cluster = "cluster01"
variable datastore = "esxi01-ds01"
variable vcpu = "1"
variable memory = "1024"
variable disk_type = "thin"
variable network = "vmnet0"
variable domain = "lan"
variable datadisk0 = {
  datastore = "esxi01-ds01"
  name = "datadisk0"
  size = 10
  type = "thin"
  keep_on_remove = true
}
variable datadisk1 = {
  datastore = "esxi01-ds02"
  name = "datadisk1"
  size = 10
  type = "thin"
  keep_on_remove = true
}

provider "vsphere" {}

resource "vsphere_virtual_machine" "vm" {
  name = "${var.hostname}.${var.domain}"
  vcpu = "${var.vcpu}"
  memory = "${var.memory}"
  datacenter = "${var.region}"
  cluster = "${var.cluster}"
  skip_customization = true
  network_interface {
    label = "${var.network}"
    mac_address = "${var.mac_address}"
  }
  disk {
    datastore = "${var.datastore}"
    template  = "${var.os}-${var.os_version}"
    type = "${var.boot_disk_type}"
  }
  disk {
    datastore = "${var.datadisk0["datastore"]}"
    name = "${var.datadisk0["name"]}"
    size = "${var.datadisk0["size"]}"
    type = "${var.datadisk0["type"]}"
    keep_on_remove = "${var.datadisk0["keep_on_remove"]}"
  }
  disk {
    datastore = "${var.datadisk1["datastore"]}"
    name = "${var.datadisk1["name"]}"
    size = "${var.datadisk1["size"]}"
    type = "${var.datadisk1["type"]}"
    keep_on_remove = "${var.datadisk1["keep_on_remove"]}"
  }
  custom_configuration_parameters {
    os = "${var.os}"
    os_version = "${var.os_version}"
    hostname = "${var.hostname}.${var.domain}"
  }
}

Debug Output

Here is a sample of a test run that should create disks on multiple datastores
https://gist.github.com/dannietjoh/520edc5d41b7582efac54e0ee1f3e065

Expected Behavior

  • vm disk should have been created on esxi01-ds01
  • datadisk0 should have been created on esxi01-ds01
  • datadisk1 should have been created on esxi02-ds02

Actual Behavior

All disks are created on esxi01-ds02, inside the vm folder (It looks like it uses the last referenced datastore as when I switch the datastore definitions around everything ends op on esxi01-ds01)

I notice other arguments like ipv4_address are also ignored (not configured here)

Important Factoids

esxi/vcenter 6.5

bug providevsphere

Most helpful comment

  • keep_on_remove is completely ignored
  • detach_unknown_disks_on_delete is applied, but to the known disks, not the unknown disks

All 4 comments

  • keep_on_remove is completely ignored
  • detach_unknown_disks_on_delete is applied, but to the known disks, not the unknown disks

I'm using Centos 7.3 like you and I'm having troubles with the Guest.Net. I'm working on VSphere 6.5 and when the provider tries to get Guest.Net I'm getting 2 scenarios:

  1. If the template is built with virtualDev = e1000, Guest.Net doesn't return IP (sometime it returns the custom IP). Probably happens because the vsphere provider is using the vmxnet3 as network device type for template

  2. If the template is built with virtualDev=vmxnet3, Guest.Net returns the template IP (sometime it returns the custom IP).

I think the problem is the Customize Guest OS , because if you open a console to VM and check /etc/hosts you will see your custom IP configured, if someone has a clue of what is happening it would be great to know.

I can reproduce the behavior described by @dannietjoh.
If detach_unknown_disks_on_delete is not set then destroying a VM leaves the disk on the datastore. Subsequent VM creations creates duplicated folders on the datastore. ie:

  • server
  • server_1
  • server_2

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings