Nitesh Berwal
Nitesh Berwal

Reputation: 1

Terraform vsphere_virtual_machine working fine on older version (0.13.7) but failing on newer version (1.1.19)

I have upgraded the terraform version on the server from 0.13.7 to 1.1.19.

My code to provision vsphere_virtaul_machine (both windows and linux) works fine in the older version but when i am trying to run the exactly same code in the newer terraform version it is failing with an error "error reconfiguring virtual machine: error reconfiguring virtual machine: Invalid operation for device '0'". I have the following resource code excerpt:

data "vsphere_datacenter" "dc" {
  name = var.dc
}

data "vsphere_datastore" "datastore" {
  name          = var.datastore
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_compute_cluster" "compute_cluster" {
  name          = var.cluster
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_network" "network" {
  name          = var.networks
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_content_library" "library" {
  name = var.content_library
}

data "vsphere_content_library_item" "item" {
  type       = var.type
  name       = lookup(var.content_lib[var.content_library_env],var.os_type)
  library_id = data.vsphere_content_library.library.id
}

data "vsphere_virtual_machine" "template" {
  name          = lookup(var.content_lib[var.content_library_env],var.os_type)
  datacenter_id = data.vsphere_datacenter.dc.id
} 

resource "vsphere_virtual_machine" "vm" {
  name                   = var.vmname
  resource_pool_id       = data.vsphere_compute_cluster.compute_cluster.resource_pool_id
  datastore_id           = data.vsphere_datastore.datastore.id
  num_cpus               = var.num_cpu
  memory                 = var.memory
  folder                 = var.folder
  cpu_hot_add_enabled    = "true"
  cpu_hot_remove_enabled = "true"
  memory_hot_add_enabled = "true" 
  hardware_version       = "15"
  enable_disk_uuid       = "true"


  network_interface {
    network_id   = data.vsphere_network.network.id
  }

  disk {
    label     = "disk0"
    size      = var.disk_size
  }

  clone {
    template_uuid = data.vsphere_content_library_item.item.id

  customize {
    windows_options {
    computer_name         = var.vmname
    admin_password        = var.admin_password
    workgroup             = var.workgroup
    full_name             = var.full_name
    organization_name     = var.organization_name
    auto_logon            = var.auto_logon
    auto_logon_count      = var.auto_logon_count
    time_zone             = var.time_zone
    run_once_command_list = var.run_once_command_list
    product_key           = var.product_key_details[var.os_type]        
  }
  network_interface {
    ipv4_address  = var.ip_address != "" ? var.ip_address : null
    ipv4_netmask  = var.ip_address != "" ? var.netmask : null
  }
  dns_server_list = var.dnslist
  ipv4_gateway    = var.gateway
  }
}
}

I have checked my code several times, tried a few minor tweaks as well but it is still failing. Are there any other specific parameters in the newer version which i need to pass or is there any change in the data-source(s)/resource(s)?

Upvotes: 0

Views: 703

Answers (0)

Related Questions