diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 693d97e9b..da8ecd5c8 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -40,6 +40,7 @@ type config struct { ISOChecksum string `mapstructure:"iso_checksum"` ISOChecksumType string `mapstructure:"iso_checksum_type"` ISOUrls []string `mapstructure:"iso_urls"` + Version string `mapstructure:"version"` VMName string `mapstructure:"vm_name"` BootCommand []string `mapstructure:"boot_command"` SkipCompaction bool `mapstructure:"skip_compaction"` @@ -110,6 +111,10 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.VMName = fmt.Sprintf("packer-%s", b.config.PackerBuildName) } + if b.config.Version == "" { + b.config.Version = "9" + } + if b.config.RemoteUser == "" { b.config.RemoteUser = "root" } diff --git a/builder/vmware/iso/builder_test.go b/builder/vmware/iso/builder_test.go index f3c1dfd59..b6c0cfd81 100644 --- a/builder/vmware/iso/builder_test.go +++ b/builder/vmware/iso/builder_test.go @@ -134,6 +134,10 @@ func TestBuilderPrepare_Defaults(t *testing.T) { t.Errorf("bad output dir: %s", b.config.OutputDir) } + if b.config.Version != "9" { + t.Errorf("bad Version: %s", b.config.Version) + } + if b.config.SSHWaitTimeout != (20 * time.Minute) { t.Errorf("bad wait timeout: %s", b.config.SSHWaitTimeout) } diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 8544a1405..e490e639b 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -15,6 +15,7 @@ type vmxTemplateData struct { GuestOS string DiskName string ISOPath string + Version string } // This step creates the VMX file for the VM. @@ -41,6 +42,7 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { Name: config.VMName, GuestOS: config.GuestOSType, DiskName: config.DiskName, + Version: config.Version, ISOPath: isoPath, } @@ -180,7 +182,7 @@ tools.upgrade.policy = "upgradeAtPowerCycle" usb.pciSlotNumber = "32" usb.present = "FALSE" virtualHW.productCompatibility = "hosted" -virtualHW.version = "9" +virtualHW.version = "{{ .Version }}" vmci0.id = "1861462627" vmci0.pciSlotNumber = "35" vmci0.present = "TRUE" diff --git a/website/source/docs/builders/vmware-iso.html.markdown b/website/source/docs/builders/vmware-iso.html.markdown index 6029ff052..2ac5599f0 100644 --- a/website/source/docs/builders/vmware-iso.html.markdown +++ b/website/source/docs/builders/vmware-iso.html.markdown @@ -218,6 +218,8 @@ each category, the available options are alphabetized and described. `tools_upload_flavor`. By default the upload path is set to `{{.Flavor}}.iso`. +* `version` (string) - The [vmx hardware version](http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003746) for the new virtual machine. Only the default value has been tested, any other value is expiermental. Default value is '9'. + * `vm_name` (string) - This is the name of the VMX file for the new virtual machine, without the file extension. By default this is "packer-BUILDNAME", where "BUILDNAME" is the name of the build. @@ -334,6 +336,7 @@ these variables isn't required, however. * `GuestOS` - The VMware-valid guest OS type. * `DiskName` - The filename (without the suffix) of the main virtual disk. * `ISOPath` - The path to the ISO to use for the OS installation. +* `Version` - The Hardware version VMWare will execute this vm under. Also known as the `virtualhw.version`. ## Building on a Remote vSphere Hypervisor