hashicorp / packer-plugin-virtualbox

Packer plugin for VritualBox Builder
https://www.packer.io/docs/builders/virtualbox
Mozilla Public License 2.0
22 stars 36 forks source link

Packer Option "-Force" does not overwrite old VM #121

Open lmkrousenick opened 8 months ago

lmkrousenick commented 8 months ago

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

Using the 'packer build -force' option does not over write the existing VM, packer will fail with error the VM already exists. If I have a failed build I should be able to rerun packer and it should delete any VM with the name it is trying to create.

Reproduction Steps

Manually running 'vboxmanage unregistervm [VM NAME] --delete' and rerunning packer resolves the issue

Plugin and Packer version

Packer 1.9.5 vagrant plugin v1.1.1 virtualbox 7.0..12_159484

Operating system and Environment details

Rocky 8, x86_64

Log Fragments and crash.log files

Build 'virtualbox-iso.vbox-rocky-tpl' errored after 59 seconds 195 milliseconds: Error creating VM: VBoxManage error: VBoxManage: error: Machine settings file '/home/user/virtual_machines/rocky-tpl/rocky-tpl.vbox' already exists VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MachineWrap, interface IMachine, callee nsISupports VBoxManage: error: Context: "CreateMachine(bstrSettingsFile.raw(), bstrName.raw(), ComSafeArrayAsInParam(groups), bstrOsTypeId.raw(), createFlags.raw(), bstrCipher.raw(), bstrPasswordId.raw(), Bstr(strPassword).raw(), machine.asOutParam())" at line 406 of file VBoxManageMisc.cpp