From 7d9c252b3ab9030e1e6ae8afb5284294483118ce Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Tue, 16 Sep 2014 18:27:00 -0700 Subject: [PATCH] Clean VMX step should always remove floppy. When using the VMX builder its possible for the source machine to have a floppy configured which gets cloned to the new VM Packer spins up. When the new VM's Packer config doesn't have a floppy_files config entry, the Packer clean VMX step fails to remove the floppy disk from the new VM. This can cause build failures, for example with the vsphere post processor; generating errors like: * Post-processor failed: Failed: exit status 1 Error: File (/home/teamcity/tmp/buildTmp/packer941120499) could not be found. Opening the cloned VM's VMX file you can clearly see it has a floppy entry from the source machine's VMX file (exact same path) even though the Packer config contains no floppy_files entry. --- builder/vmware/common/step_clean_vmx.go | 16 +++++++--------- builder/vmware/common/step_clean_vmx_test.go | 1 - 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go index b55bcd549..9c677e3a8 100644 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -32,17 +32,15 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - if _, ok := state.GetOk("floppy_path"); ok { - // Delete the floppy0 entries so the floppy is no longer mounted - ui.Message("Unmounting floppy from VMX...") - for k, _ := range vmxData { - if strings.HasPrefix(k, "floppy0.") { - log.Printf("Deleting key: %s", k) - delete(vmxData, k) - } + // Delete the floppy0 entries so the floppy is no longer mounted + ui.Message("Unmounting floppy from VMX...") + for k, _ := range vmxData { + if strings.HasPrefix(k, "floppy0.") { + log.Printf("Deleting key: %s", k) + delete(vmxData, k) } - vmxData["floppy0.present"] = "FALSE" } + vmxData["floppy0.present"] = "FALSE" if isoPathRaw, ok := state.GetOk("iso_path"); ok { isoPath := isoPathRaw.(string) diff --git a/builder/vmware/common/step_clean_vmx_test.go b/builder/vmware/common/step_clean_vmx_test.go index 59877027a..73a8abf45 100644 --- a/builder/vmware/common/step_clean_vmx_test.go +++ b/builder/vmware/common/step_clean_vmx_test.go @@ -39,7 +39,6 @@ func TestStepCleanVMX_floppyPath(t *testing.T) { t.Fatalf("err: %s", err) } - state.Put("floppy_path", "foo") state.Put("vmx_path", vmxPath) // Test the run