-1

With packer I can script up the creation of a template linux box and upload to my vsphere cloud instance as a vmware box. I'd like it to be uploaded or converted to a vsphere template so then I can run terraform on this template to automate the creation of multiple linux based VMs. How can I do this? I currently need to manually right click on the uploaded VM in vsphere and click "Convert to Template" at which point terraform will happily generate and customise multiple instances of the base linux box.

Is there a mechanism with packer/terraform for automating this? If so what is it?

jiopaley
  • 126
  • 1
  • 7

1 Answers1

0

The disk/template section in the terraform file does not only apply to vsphere templates. For example the following will initiate a clone of the BaseLinuxVM in vsphere:

resource "vsphere_virtual_machine" "my-first-vm" {
 datacenter        = "MyDatacenter"
 cluster = "MyCluster"
 name = "my-first-vm"
 memory = 1024
 vcpu = 1

 disk {
  datastore = "MyDatastore"
  template = "BaseLinuxVM" 
 }
 linked_clone = false
 network_interface {
  label = "VM Network"
 }
}
jiopaley
  • 126
  • 1
  • 7