This post-processor will upload a VMDK and vmware template to a datastore through VSphere 5.5
Software:
- A Local hypervisor for Packer to use during the build:
- VMware OVF Tool (4.1.0) Download from VMWare
- vSphere 5.5 (will likely work on 6, but untested)
Notes:
- This post processor should work with the Virtualbox and the VMware Packer builders
Pull the repository and compile the code with go build
Add
{
"post-processors": {
"vsphere-ova": "packer-post-processor-vsphere-ova"
}
}
to your packer configuration (see: http://www.packer.io/docs/other/core-configuration.html -> Core Configuration)
Make sure that the directory which contains the packer-post-processor-vsphere-ova executable is your PATH environmental variable (see http://www.packer.io/docs/extend/plugins.html -> Installing Plugins)
Add the following, filled out correctly to your post-processors and you should end up with packer-virutalbox-timestamp-vm
registered on your cluster as a template.
I'm not sure if a release of Packer with SCSI support has been released yet, but you can create a virtualbox with a SCSI drive using Packer for maximum performance on your VMWare setup.
There is some wierdness with how this works:
- It uploads a virtual machine
- It registers a virtual machine
- It clones the virtual machine (it complains about invalid device backing without this)
- It powers on the cloned virtual machine
- It SLEEPS for 2ish minutes while we wait for power on to complete
- It powers off the cloned virtual machine
- It marks the cloned virtual machine as a template.
- You end up with a registered template of the vm name with "-vm" appended.
This is the statement you need to add to your packer json file:
"post-processors": [
{
"type": "vsphere-ova",
"host":"vcenter_host",
"datacenter":"datacenter_name",
"username":"my_username",
"password":"my_password",
"datastore": "datastore_name",
"vm_folder":"folder_on_datastore",
"vm_network":"vmware_network_name"
}
]
You also will need "format": "ova"
in your virtualbox-iso builder for this to function.
NOTE: This will produce the default behavior described above, you can avoid steps 3-6 if you remove the Floppy, Optical Drive, and Ethernet devices prior to upload. See below for how to do this.
Add "virtual_hardware_version": "n"
to the post-processor config in your packer template. Where 'n' is the desired version. Default: 10
Add "remove_floppy": "true"
to the post-processor config in your packer template.
Add "remove_ethernet": "true"
to the post-processor config in your packer template.
Add "remove_optical_drive": "true"
to the post-processor config in your packer template.
Add "remove_floppy": "true", "remove_ethernet": "true", "remove_optical_drive": "true"
to the post-processor config in your packer template.
NOTE: This makes the "vm_network": "vmware_network_name"
parameter optional.