Packer 1.1.3/1.1.2 not disconnecting cdrom after VMware Template creation.

570 views
Skip to first unread message

Mukarram

unread,
Dec 19, 2017, 10:22:09 PM12/19/17
to Packer
Hi Guys,
I know you've seen this problem before, however I am having the issue now.
I have tried these settings about a 100 times in the last 2 days but none of them work.

Basically  the "vm_data_post" does not work...at least it looks that way:

I tried this:
    "vmx_data_post": {
        "ide1:0.startConnected": "TRUE",
        "ide1:0.clientDevice": "TRUE",
        "ide1:0.fileName": "emptyBackingString"
    },

This:
    "vmx_data_post": {
"ide1:0.deviceType" : "atapi-cdrom",
"ide1:0.fileName" : "emptyBackingString",
"ide1:0.present" : "TRUE",
"ide1:0.clientDevice" : "TRUE"
  },

And also I tried the "inline" in the "post-processor" section with the "vmware-cmd" script, that also didn't work.  It "invalidates" the VM.
So before I create the template, I start the VM, try to disconnect the "CD/DVD drive 1" and then power off the VM.

  "post-processors": [
     [
       {
        "inline": [
          "/opt/scripts/vmware-perl-sdk/bin/vmware-cmd -U {{ user `source_esxi_user` }} -P {{ user `source_esxi_password` }} -H {{ user `VCENTER_IP` }} --vihost {{ user `REMOTE_ESXI` }} /vmfs/volumes/{{ user `REMOTE_DATASTORE` }}/output-vmware-iso/{{ user `vm_name` }}.vmx start soft",
          "/opt/scripts/vmware-perl-sdk/bin/vmware-cmd -U {{ user `source_esxi_user` }} -P {{ user `source_esxi_password` }} -H {{ user `VCENTER_IP` }} --vihost {{ user `REMOTE_ESXI` }} /vmfs/volumes/{{ user `REMOTE_DATASTORE` }}/output-vmware-iso/{{ user `vm_name` }}.vmx disconnectdevice \"CD/DVD drive 1\"",
          "/opt/scripts/vmware-perl-sdk/bin/vmware-cmd -U {{ user `source_esxi_user` }} -P {{ user `source_esxi_password` }} -H {{ user `VCENTER_IP` }} --vihost {{ user `REMOTE_ESXI` }} /vmfs/volumes/{{ user `REMOTE_DATASTORE` }}/output-vmware-iso/{{ user `vm_name` }}.vmx suspend soft"
        ],
        "type": "shell-local"
       }
     ]

So I am outta luck now.

Please help.

# mukarram

Mukarram

unread,
Dec 21, 2017, 11:48:47 AM12/21/17
to Packer
Hi.

Any help is appreciated.

Thanks

# mukarram

Alvaro Miranda Aguilera

unread,
Dec 21, 2017, 12:41:21 PM12/21/17
to packe...@googlegroups.com
when you weite 1.1.3/1.1.2 have issues, that means 1.1.1 and earlier do have not ?

What os is the guest os ?

Alvaro



--
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/7fbceda7-ad74-40d4-b863-57b80a339186%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Mukarram

unread,
Dec 21, 2017, 1:25:44 PM12/21/17
to Packer
Hi Alvaro,

The guest OS is CentOS 7.4

Thanks for the reply

Regards

# mukarram
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

Mukarram

unread,
Dec 21, 2017, 1:29:15 PM12/21/17
to Packer
I have only tried to use 1.1.3 and 1.1.2....both these don't disconnect the "CD/DVD1 - Datastore ISO file".  However I tried the 0.98 (I believe)...which errors out when I use the "vsphere-template" in the Post Processor.
Having said this, I haven't tried any other Packer versions.

Thanks

# mukarram

Mukarram

unread,
Dec 21, 2017, 2:07:49 PM12/21/17
to Packer
Hi Alvaro,

Here is my Packer Json file for your information.

Thanks

# mukarram


{
  "variables": {
  },
  "builders": [{
    "type": "vmware-iso",
    "iso_url": "{{ user `ISO_URL` }}",
    "iso_checksum" : "{{ user `ISO_CHECKSUM` }}",
    "iso_checksum_type" : "md5",
    "disk_type_id": "thin",
    "disk_size": "200000",
    "output_directory": "{{ user `vm_name` }}",
    "vmx_data": {
        "memsize": "4096",
        "numvcpus": "2",
        "ethernet0.networkName": "{{ user `KS_NET` }}",
        "ethernet0.virtualDev": "vmxnet3",
        "ethernet0.present": "TRUE"
     },
    "boot_command" : [
       "<tab> text ks=http://kickstart/kickstart/{{ user `KS_URL` }}<enter><wait>"
    ],
    "boot_wait" : "30s",
    "ssh_timeout" : "1000s",
    "ssh_username": "{{user `ssh_user`}}",
    "ssh_password": "{{user `ssh_password`}}",
    "remote_datastore": "{{ user `REMOTE_DATASTORE` }}",
    "remote_host": "{{ user `REMOTE_ESXI` }}",
    "remote_password": "{{user `source_esxi_password`}}",
    "remote_type": "ex5",
    "remote_username": "{{user `source_esxi_user`}}",
    "version": "11",
    "vm_name": "{{user `vm_name`}}",
    "vmdk_name": "{{user `vm_name`}}",
    "keep_registered": "true",
    "shutdown_command": "/usr/bin/sudo /sbin/shutdown -h now"
  }],
  "post-processors": [
    {
   "type": "vsphere-template",
   "host": "{{ user `VCENTER_IP` }}",
   "insecure": true,
   "datacenter": "{{ user `vcenter_dc` }}",
   "username": "{{user `vcenter_user`}}",
   "password": "{{user `source_esxi_password`}}",
   "folder": "/Templates"
  }]
}

Mukarram

unread,
Dec 21, 2017, 2:09:27 PM12/21/17
to Packer
Also I tried "headless: false" and that didn't work either.

Thanks

# mukarram

On Thursday, December 21, 2017 at 10:29:15 AM UTC-8, Mukarram wrote:

Alvaro Miranda Aguilera

unread,
Dec 21, 2017, 3:36:46 PM12/21/17
to packe...@googlegroups.com
have you tried to add an eject to the kickstart ?

its the OS iso the one that keeps mounted?

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/e146aa8a-24ef-49ae-8851-44353372bd8a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Mukarram

unread,
Dec 22, 2017, 7:10:54 PM12/22/17
to Packer
Hi Alvaro,

Thank you for the suggestion.

Adding
reboot --eject
to kickstart .ks file did not eject the cdrom or the Datastore ISO.

Here is the logs from packer below.
It says that it's detaching the ISO but after the "vsphere-template" runs, it attaches back the ISO.
When I comment out the "vsphere-template" part the Datastore ISO is detached.  It's only when it converts to a template when the ISO gets attached.

Thanks for the help.
Happy Holidays.

# mukarram

vmware-iso output will be in this color.

==> vmware-iso: Downloading or copying ISO
    vmware-iso: Downloading or copying: file:///var/www/html/ISOs/CentOS-7-x86_64-Minimal-1708.iso
==> vmware-iso: Uploading ISO to remote machine...
==> vmware-iso: Creating virtual machine disk
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Registering remote VM...
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 30s for boot...
==> vmware-iso: Connecting to VM via VNC
==> vmware-iso: Typing the boot command over VNC...
==> vmware-iso: Waiting for SSH to become available...
==> vmware-iso: Connected to SSH!
==> vmware-iso: Gracefully halting virtual machine...
    vmware-iso: Waiting for VMware to clean up after itself...
==> vmware-iso: Deleting unnecessary VMware files...
    vmware-iso: Deleting: /vmfs/volumes/hx-ds1/CentOS-7-Corp-Template-TEST/vmware.log
==> vmware-iso: Compacting the disk image
==> vmware-iso: Cleaning VMX prior to finishing up...
    vmware-iso: Unmounting floppy from VMX...
    vmware-iso: Detaching ISO from CD-ROM device...
    vmware-iso: Disabling VNC server...
==> vmware-iso: Skipping export of virtual machine (export is allowed only for ESXi and the format needs to be specified)...
==> vmware-iso: Keeping virtual machine registered with ESX host (keep_registered = true)
==> vmware-iso: Running post-processor: vsphere-template
    vmware-iso (vsphere-template): Waiting 10s for VMware vSphere to start
    vmware-iso (vsphere-template): Choosing datacenter...
    vmware-iso (vsphere-template): Creating or checking destination folders...
    vmware-iso (vsphere-template): Marking as a template...
Build 'vmware-iso' finished.

==> Builds finished. The artifacts of successful builds are:
--> vmware-iso: VM files in directory: /vmfs/volumes/hx-ds1/CentOS-7-Corp-Template-TEST
--> vmware-iso:

Reply all
Reply to author
Forward
0 new messages