-
Notifications
You must be signed in to change notification settings - Fork 106
Description
Overview of the Issue
Currently, when running packer build -force with the vsphere-clone builder, if the specified source virtual machine is missing, Packer proceeds to delete the target virtual machine before verifying that the source is available. This behavior risks data loss, especially in cases where the target VM is unique and has no backup or proper build configuration.
One of the use cases is when Packer is used to regularly update legacy virtual machine templates that are unique and cannot be recreated. Running packer build -force without verifying the source VM can lead to data loss, especially when human error or misconfiguration occurs.
Reproduction Steps
- Have a
templateset to non-existing virtual machine - Run
packer build -force - Observe that the target VM is deleted before confirming that a source VM is available.
Expected Behavior
vsphere-clonebuilder should first check if the source VM exists before force-deleting the target VM.- If the source VM is missing, the build process should exit without affecting the target VM.
Packer Version
Packer v1.11.2
Plugin Version and Builders
Plugin version 1.4.2
-
vsphere-iso -
vsphere-clone
VMware vSphere Version
Please provide the VMware vSphere version.
- 7.0.3
Guest Operating System
Any
Simplified Packer Buildfile
Basicvsphere-clone configuration; template option is set to a non-existing virtual machine.
Operating System and Environment Details
Any
Log Fragments and crash.log Files
2024-11-11T07:39:34Z: ==> vsphere-clone.vm: the vm/template packer-live-folder/packer-test-vm already exists, but deleting it due to -force flag
2024-11-11T07:39:34Z: ==> vsphere-clone.vm: packer-live-folder/packer-test-vm is a template, attempting to convert it to a vm
2024-11-11T07:39:36Z: ==> vsphere-clone.vm: Cloning virtual machine...
2024-11-11T07:39:36Z: vsphere-clone.vm: Closing sessions ....
2024-11-11T07:39:36Z: Build 'vsphere-clone.vm' errored after 1 second 989 milliseconds: error finding virtual machine to clone: vm 'packer-build-folder/packer-test-vm' not found