vmware-iso builder

294 views
Skip to first unread message

Rich Siegel

unread,
May 23, 2017, 6:30:07 PM5/23/17
to Packer
I am attempting to build a template on ESX (Vsphere 5.5) using packer.  I have the remote type set to esx5.  I am building from a win7 enterprise x64 desktop.

This part I am not sure about - I want to make a template, so I have added a post-processor type vsphere.  Is this the right thing to do?  If I remove the section below, packer completes successfully and reports:

==> Builds finished. The artifacts of successful builds are:
--> vmware-iso: VM files in directory: /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10

In this scenario w/o the post-processor, the log reports all the artifacts on that volume, and I have confirmed they are there.
However in Vsphere I see an orphaned computer object.  

So how do I finish this so my end result is a proper vm/template?



  "post-processors": [
    {
    "type": "vsphere",
    "host": "{{ user `vsphere_host` }}",
    "cluster": "{{ user `vsphere_cluster` }}",
    "datacenter": "{{ user `vsphere_datacenter` }}",
    "datastore": "{{ user `vsphere_datastore` }}",
    "username": "{{ user `vsphere_username` }}",
    "password": "{{ user `vsphere_password` }}",
    "vm_network": "{{ user `vsphere_vm_network` }}",
    "vm_folder": "/",
    "vm_name": "windows10-template",
    "insecure": "true",
    "disk_mode": "thin"
    }
  ]




This is the last page of the log file
2017/05/23 17:43:53 ui: ==> vmware-iso: Cleaning VMX prior to finishing up...
2017/05/23 17:43:53 ui:     vmware-iso: Unmounting floppy from VMX...
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Deleting key: floppy0.filename
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Deleting key: floppy0.filetype
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Deleting key: floppy0.present
2017/05/23 17:43:53 ui:     vmware-iso: Disabling VNC server...
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Writing VMX to: C:\Users\DAO~1.RIC\AppData\Local\Temp\packer-vmx760098881\windows10.vmx
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 opening new ssh session
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Starting remote scp process:  scp -vt /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Started SCP session, beginning transfers...
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Copying input data into temporary file so we can read the length
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 [DEBUG] scp: Uploading windows10.vmx: perms=C0644 size=3068
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 SCP session complete, closing stdin pipe.
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 Waiting for SSH session to complete.
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 scp stderr (length 31): Sink: C0644 3068 windows10.vmx
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 opening new ssh session
2017/05/23 17:43:53 packer.exe: 2017/05/23 17:43:53 starting remote command: vim-cmd vmsvc/reload 290
2017/05/23 17:43:54 packer.exe: 2017/05/23 17:43:54 opening new ssh session
2017/05/23 17:43:54 packer.exe: 2017/05/23 17:43:54 starting remote command: vim-cmd vmsvc/power.getstate 290
2017/05/23 17:43:55 ui: ==> vmware-iso: Unregistering virtual machine...
2017/05/23 17:43:55 packer.exe: 2017/05/23 17:43:55 opening new ssh session
2017/05/23 17:43:55 packer.exe: 2017/05/23 17:43:55 starting remote command: vim-cmd vmsvc/unregister 290
2017/05/23 17:43:56 packer.exe: 2017/05/23 17:43:56 Deleting floppy disk: C:\Users\DAO~1.RIC\AppData\Local\Temp\packer242371319
2017/05/23 17:43:56 packer.exe: 2017/05/23 17:43:56 opening new ssh session
2017/05/23 17:43:56 packer.exe: 2017/05/23 17:43:56 starting remote command: ls -1p /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10
2017/05/23 17:43:56 ui: ==> vmware-iso: Running post-processor: vsphere
2017/05/23 17:43:56 ui:     vmware-iso (vsphere): Uploading /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10/windows10.vmx to vSphere
2017/05/23 17:43:56 packer.exe: 2017/05/23 17:43:56 Starting ovftool with parameters: --acceptAllEulas --name=windows10-template --datastore=NETAPP_01_DEV_SAS --noSSLVerify=true --diskMode=thin --network=VM Network 10.5.12.x /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10/windows10.vmx vi://root:<password>@tp-nj-dev-esx-01.3rdpoint.corp/TP DataCenter/host/tp-nj-dev-esx-01.3rdpoint.corp
2017/05/23 17:43:56 Deleting original artifact for build 'vmware-iso'
2017/05/23 17:43:56 packer.exe: 2017/05/23 17:43:56 opening new ssh session
2017/05/23 17:43:56 packer.exe: 2017/05/23 17:43:56 starting remote command: rm -rf /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10
2017/05/23 17:43:56 ui error: Build 'vmware-iso' errored: 1 error(s) occurred:

* Post-processor failed: Failed: exit status 3221225781
2017/05/23 17:43:56 Builds completed. Waiting on interrupt barrier...
2017/05/23 17:43:56 machine readable: error-count []string{"1"}
2017/05/23 17:43:56 ui error: 
==> Some builds didn't complete successfully and had errors:
2017/05/23 17:43:56 machine readable: vmware-iso,error []string{"1 error(s) occurred:\n\n* Post-processor failed: Failed: exit status 3221225781\n"}
2017/05/23 17:43:56 ui error: --> vmware-iso: 1 error(s) occurred:

* Post-processor failed: Failed: exit status 3221225781
2017/05/23 17:43:56 ui: 
==> Builds finished but no artifacts were created.
2017/05/23 17:43:56 waiting for all plugin processes to complete...
2017/05/23 17:43:56 C:\packer\packer.exe: plugin process exited
2017/05/23 17:43:56 C:\packer\packer.exe: plugin process exited
2017/05/23 17:43:56 C:\packer\packer.exe: plugin process exited

Rich Siegel

unread,
May 23, 2017, 6:49:09 PM5/23/17
to Packer
I fixed an issue with ovftool being the wrong version in the path, and I get nearly a similar result but different exit status.

I think I am confused about which path is supposed to be used by ovftool.  Is this running on the client, or on the esx ? 

/vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10/windows10.vmx
C:\Users\DAO~1.RIC\AppData\Local\Temp\packer-vmx791048129\windows10.vmx



2017/05/23 18:39:30 ui: ==> vmware-iso: Cleaning VMX prior to finishing up...
2017/05/23 18:39:30 ui:     vmware-iso: Unmounting floppy from VMX...
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Deleting key: floppy0.present
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Deleting key: floppy0.filetype
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Deleting key: floppy0.filename
2017/05/23 18:39:30 ui:     vmware-iso: Disabling VNC server...
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Writing VMX to: C:\Users\DAO~1.RIC\AppData\Local\Temp\packer-vmx791048129\windows10.vmx
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 opening new ssh session
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Starting remote scp process:  scp -vt /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Started SCP session, beginning transfers...
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Copying input data into temporary file so we can read the length
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 [DEBUG] scp: Uploading windows10.vmx: perms=C0644 size=3068
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 SCP session complete, closing stdin pipe.
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 Waiting for SSH session to complete.
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 scp stderr (length 31): Sink: C0644 3068 windows10.vmx
2017/05/23 18:39:30 packer.exe: 2017/05/23 18:39:30 opening new ssh session
2017/05/23 18:39:31 packer.exe: 2017/05/23 18:39:31 starting remote command: vim-cmd vmsvc/reload 292
2017/05/23 18:39:31 packer.exe: 2017/05/23 18:39:31 opening new ssh session
2017/05/23 18:39:31 packer.exe: 2017/05/23 18:39:31 starting remote command: vim-cmd vmsvc/power.getstate 292
2017/05/23 18:39:32 ui: ==> vmware-iso: Unregistering virtual machine...
2017/05/23 18:39:32 packer.exe: 2017/05/23 18:39:32 opening new ssh session
2017/05/23 18:39:32 packer.exe: 2017/05/23 18:39:32 starting remote command: vim-cmd vmsvc/unregister 292
2017/05/23 18:39:33 packer.exe: 2017/05/23 18:39:33 Deleting floppy disk: C:\Users\DAO~1.RIC\AppData\Local\Temp\packer871765111
2017/05/23 18:39:33 packer.exe: 2017/05/23 18:39:33 opening new ssh session
2017/05/23 18:39:33 packer.exe: 2017/05/23 18:39:33 starting remote command: ls -1p /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10
2017/05/23 18:39:33 ui: ==> vmware-iso: Running post-processor: vsphere
2017/05/23 18:39:33 ui:     vmware-iso (vsphere): Uploading /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10/windows10.vmx to vSphere
2017/05/23 18:39:33 packer.exe: 2017/05/23 18:39:33 Starting ovftool with parameters: --acceptAllEulas --name=windows10-template --datastore=NETAPP_01_DEV_SAS --noSSLVerify=true --diskMode=thin --vmFolder=/ --network=VM Network 10.5.12.x /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10/windows10.vmx vi://root:<password>@tp-nj-dev-esx-01.3rdpoint.corp/TP DataCenter/host/TP DEV Cluster
2017/05/23 18:39:34 Deleting original artifact for build 'vmware-iso'
2017/05/23 18:39:34 packer.exe: 2017/05/23 18:39:34 opening new ssh session
2017/05/23 18:39:34 packer.exe: 2017/05/23 18:39:34 starting remote command: rm -rf /vmfs/volumes/NETAPP_01_DEV_SAS/output-windows10
2017/05/23 18:39:34 ui error: Build 'vmware-iso' errored: 1 error(s) occurred:

* Post-processor failed: Failed: exit status 1
2017/05/23 18:39:34 Builds completed. Waiting on interrupt barrier...
2017/05/23 18:39:34 machine readable: error-count []string{"1"}
2017/05/23 18:39:34 ui error: 
==> Some builds didn't complete successfully and had errors:
2017/05/23 18:39:34 machine readable: vmware-iso,error []string{"1 error(s) occurred:\n\n* Post-processor failed: Failed: exit status 1\n"}
2017/05/23 18:39:34 ui error: --> vmware-iso: 1 error(s) occurred:

* Post-processor failed: Failed: exit status 1
2017/05/23 18:39:34 ui: 
==> Builds finished but no artifacts were created.
2017/05/23 18:39:34 waiting for all plugin processes to complete...
2017/05/23 18:39:34 C:\packer\packer.exe: plugin process exited
2017/05/23 18:39:34 C:\packer\packer.exe: plugin process exited
2017/05/23 18:39:34 C:\packer\packer.exe: plugin process exited

Rickard von Essen

unread,
May 24, 2017, 1:09:49 AM5/24/17
to packe...@googlegroups.com
First of all, there is WIP PR for adding a vSphere builder. You probably want to subscribe to that. 

The vSphere post-processor runs ovftool locally. 

I think that your best option is to use the shell-local post-processor to invoke govomi to convert the VM to a template. The vSphere post-processor is more suitable when building locally with Workstation and the uploading the result to vSphere. 

--
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/1733bcd7-c58c-4781-a611-9a9af583be14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rich Siegel

unread,
May 24, 2017, 5:29:05 PM5/24/17
to Packer
Thanks for the reply.  This is what I had thought, but I think the piece I was missing was the keep_registered option.  I would have expected this to be default true if using esx5 (ssh approach). 
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages