Custom attributes in VMX file not persisting after ovftool cloning

261 views
Skip to first unread message

John C

unread,
Jun 2, 2017, 4:52:36 PM6/2/17
to Packer
I'm using Packer to build a Windows 21012 R2 server image for our VMware ESXi environment, with all of the code stored in a local GitHub repository.  During the Packer image build process, I get the short SHA associated with the GitHub commit and then add that to the VMX file as a custom attribute, so we can associate that image back to the GitHub commit later.  While the image is building, the custom attribute is definitely in the VMX file, but once it's fully built and OVFTOOL takes over to clone it to other ESXi locations, this custom attribute is not present in the cloned image.  Is there a way to persist this custom VMX data throughout the entire Packer image build process, start to finish?  Thanks.

Alvaro Miranda Aguilera

unread,
Jun 3, 2017, 3:35:13 PM6/3/17
to packe...@googlegroups.com
Hello

How are you adding the value to the VMX?

Are 2 parameters, one for the build and one before the export.

Be sure to add it to both and should do what you are after:

  • vmx_data (object of key/value strings) - Arbitrary key/values to enter into the virtual machine VMX file. This is for advanced users who want to set properties such as memory, CPU, etc.

  • vmx_data_post (object of key/value strings) - Identical to vmx_data, except that it is run after the virtual machine is shutdown, and before the virtual machine is exported.



On Fri, Jun 2, 2017 at 10:52 PM, John C <johnn...@gmail.com> wrote:
I'm using Packer to build a Windows 21012 R2 server image for our VMware ESXi environment, with all of the code stored in a local GitHub repository.  During the Packer image build process, I get the short SHA associated with the GitHub commit and then add that to the VMX file as a custom attribute, so we can associate that image back to the GitHub commit later.  While the image is building, the custom attribute is definitely in the VMX file, but once it's fully built and OVFTOOL takes over to clone it to other ESXi locations, this custom attribute is not present in the cloned image.  Is there a way to persist this custom VMX data throughout the entire Packer image build process, start to finish?  Thanks.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/d9aab02e-a616-4b8b-99b2-8a6eae18846c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

John C

unread,
Jun 5, 2017, 3:18:25 PM6/5/17
to Packer
Thanks Alvaro.  I was originally using the vmx_data attribute value in the Packer JSON file, and using that it does appear when the template is being built, but then not after it's exported to remote vCenter locations.  I added the same attribute into  vmx_post_data  and that had the same effect where the custom attribute is still present in the VMX file on the target vCenter after the export completed.  

Any other suggestions?  The debug log shows this in a few different places ... "Pausing after run of step 'StepCleanVMX'. Press enter to continue."  Do I need to reorder my steps in such a way that the clean happens after the attribute is written to the VMX file?  Or add a command into the post-provisioner to address this?

Thanks,
John

John C

unread,
Jun 5, 2017, 3:20:16 PM6/5/17
to Packer
CORRECTION : The attribute is not present in the VMX data file after export, the original post seemed to suggest otherwise ... thanks.

===================================================

Thanks Alvaro.  I was originally using the vmx_data attribute value in the Packer JSON file, and using that it does appear when the template is being built, but then not after it's exported to remote vCenter locations.  I added the same attribute into  vmx_post_data  and that had the same effect where the custom attribute is still NOT present in the VMX file on the target vCenter after the export completed.  

Any other suggestions?  The debug log shows this in a few different places ... "Pausing after run of step 'StepCleanVMX'. Press enter to continue."  Do I need to reorder my steps in such a way that the clean happens after the attribute is written to the VMX file?  Or add a command into the post-provisioner to address this?

Thanks,
John



On Friday, June 2, 2017 at 1:52:36 PM UTC-7, John C wrote:

Blake Garner

unread,
Jun 21, 2017, 2:49:49 PM6/21/17
to Packer
We also track the git revision of the packer builds in a resulting .ova file for VMware. After a lot of other attempted approaches managing the .ovf xml directly and storing it in git seemed like the best solution for us. I resorted to hand building the .ovf xml descriptor and storing it in the git project. A shell script updates the xml and then joins the packer made .vmdk to the .ovf  via ovftool to create a resulting .ova. 
Reply all
Reply to author
Forward
0 new messages