How do I adjust the Computer Name property in vmWare Cloud Director using Terraform?

Viewed 450

I am trying to set up a new vApp with three VM's using Terraform's vcd provider. I have a template named ubuntu-template. When I create the vApp and associated VM's using Terraform, I can see that the virtual machine name is changed to the value I specified, however the Computer Name is still set to 'ubuntu-template'. This means that the hostnames of all three VM's are 'ubuntu-template'. Is there a way to specify the Computer Name property using Terraform or by some other method?

resource "vcd_vapp" "ordswarmmasters" {
  name = "ordswarmmasters"
  power_on = true
}

resource "vcd_vapp_vm" "ordswarmmaster1" {
  depends_on    = ["vcd_vapp.ordswarmmasters"]
  vapp_name     = "${vcd_vapp.ordswarmmasters.name}"
  name          = "ordswarmmaster1"
  catalog_name  = "ORD"
  template_name = "ubuntu-template"
  memory        = 4096
  cpus          = 2
  cpu_cores     = 1
  power_on      = true

  network_name  = "ORD-NET"
  ip            = "dhcp"
}

So for the above code I have a vApp named 'ordswarmmasters' and a VM where the Virtual Machine Name is 'ordswarmmaster1', but the Computer Name in the properties remains 'ubuntu-template'.

1 Answers

Looks like if you provide an initscript it will adjust the Computer Name value. I put a simple initscript in of touch /tmp/testfile and that was enough to get it working.

Related