diff --git a/builder/vmware/builder.go b/builder/vmware/builder.go index 8f3ff4fdf..a9acaeb5d 100644 --- a/builder/vmware/builder.go +++ b/builder/vmware/builder.go @@ -1,6 +1,7 @@ package vmware import ( + "github.com/mitchellh/mapstructure" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" ) @@ -14,11 +15,17 @@ type Builder struct { type config struct { DiskName string `mapstructure:"vmdk_name"` + ISOUrl string `mapstructure:"iso_url"` VMName string `mapstructure:"vm_name"` OutputDir string `mapstructure:"output_directory"` } func (b *Builder) Prepare(raw interface{}) (err error) { + err = mapstructure.Decode(raw, &b.config) + if err != nil { + return + } + if b.config.DiskName == "" { b.config.DiskName = "disk" } diff --git a/builder/vmware/step_create_vmx.go b/builder/vmware/step_create_vmx.go index 2383a3dac..02b95d11b 100644 --- a/builder/vmware/step_create_vmx.go +++ b/builder/vmware/step_create_vmx.go @@ -13,6 +13,7 @@ type vmxTemplateData struct { Name string GuestOS string DiskName string + ISOPath string } type stepCreateVMX struct{} @@ -32,6 +33,7 @@ func (stepCreateVMX) Run(state map[string]interface{}) multistep.StepAction { config.VMName, "ubuntu-64", config.DiskName, + config.ISOUrl, } t := template.Must(template.New("vmx").Parse(DefaultVMXTemplate)) @@ -71,6 +73,9 @@ gui.fullScreenAtPowerOn = "FALSE" gui.viewModeAtPowerOn = "windowed" hgfs.linkRootShare = "TRUE" hgfs.mapRootShare = "TRUE" +ide1:0.present = "TRUE" +ide1:0.fileName = "{{ .ISOPath }}" +ide1:0.deviceType = "cdrom-image" isolation.tools.hgfs.disable = "FALSE" memsize = "512" nvram = "{{ .Name }}.nvram"