VMware Cloud Community
Petersaints
Enthusiast
Enthusiast

Update UUID of VM Template

Hello all,

DEVOps team ask me for help because they are using Terraform as infrastructure lifecycle management framework that among other things creates, changes and destroy virtual machines.

   When requesting to create a VM, Terraform templates selects VM/VApp Template based on its name.
    When created, Terraform stores the UUID of the template in a "statefile". This state file basically is used to achieve idempotency, meaning, that when executed again, Terraform will only apply changes, and here starts the challenge (at least to me) Smiley Happy.

    We have multiple templates (OS flavors, etc) and the problem is, whenever, for some reason, we need to update a template, in fact from a VMware perspective is a new template (distinct UUID).
    This creates a situation where we need to keep all the versions of templates, as long as there is a VM that was provisioned with it. If we delete a template, whenever we execute the Terraform it will notice that the UUID doesn't exist which in some situations origins the destroy and create a new VM, which is not desirable.

So, we are looking for an approach where we could keep the UUID on VM Template. Is there a procedure to do that? How could we achieve this? for instance using a powercli command/script where UUID of template would be update (we understand the risks that this could involve in case of failure, like duplicate UUIDs or similar).
We use Hashicorp Packer to maintain a continuous integration/continuous delivery Pipeline for VM Templates so any GUI driven approach isn't viable!

Can anyone help?

Thanks.

Regards

0 Kudos
3 Replies
Lalegre
Virtuoso
Virtuoso

Hey Petersaints​,

Have you identified which ID uses? It could be the BIOS UUID but I suspect it uses the MoReF ID that vCenter uses, could you please confirm this?

0 Kudos
Petersaints
Enthusiast
Enthusiast

Hi Lalegre​,

It's the BIOS UUID.

Thanks!

0 Kudos
Lalegre
Virtuoso
Virtuoso

Hey,

So yes you can keep the BIOS UUID of the template by editing the .vmtx file but this will only apply if the Template exists, if you delete it of course it will have a new BIOS UUID: VMware Knowledge Base

However doing this for all the new VMs I suspect you will have the same BIOS UUID and I am not 100% sure about the impact but a lot of applications uses this ID to identify the VMs so they will not understand which VM are you talking about.

0 Kudos