Packer fails to complete because output directory does not exist

1,241 views
Skip to first unread message

Steven Langlois

unread,
Oct 6, 2016, 6:27:00 PM10/6/16
to Packer
When building the VM on an ESX server, everything is working but it fails at the very end when it is about to put the files in the output directory and complains that the output directory does not exist. 

A very similar json (only the network information is different) with the same kickstart file runs fine when I have VM Player on the same machine that where packer is installed but when I use the ESX server I get the following output.

If I create the output directory, it says it works and the files will be put into the output directory but after completion, the output directory is empty. The files are on the ESX server datastore but not on the machine where Packer is installed. When building on an ESX server, is the output directory relative to the local machine or is relative to the ESX datastore?

I've also noticed that after completion, the VM on the ESX server is orphaned. I cannot power it on.

I've attached the json and debug log information from packer.

==> vmware-iso: Compacting the disk image

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Writing VMX to: /tmp/packer-vmx816374223/centos-7.2-x86_64.vmx

2016/10/06 17:37:40 ui: ==> vmware-iso: Cleaning VMX prior to finishing up...

==> vmware-iso: Cleaning VMX prior to finishing up...

2016/10/06 17:37:40 ui:     vmware-iso: Unmounting floppy from VMX...

    vmware-iso: Unmounting floppy from VMX...

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Deleting key: floppy0.present

2016/10/06 17:37:40 ui:     vmware-iso: Detaching ISO from CD-ROM device...

    vmware-iso: Detaching ISO from CD-ROM device...

2016/10/06 17:37:40 ui:     vmware-iso: Disabling VNC server...

    vmware-iso: Disabling VNC server...

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Writing VMX to: /tmp/packer-vmx816374223/centos-7.2-x86_64.vmx

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 opening new ssh session

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Starting remote scp process:  scp -vt /vmfs/volumes/Datastore2/zr-centos-7.2-x86_64-vmware

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Started SCP session, beginning transfers...

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Copying input data into temporary file so we can read the length

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 [DEBUG] scp: Uploading centos-7.2-x86_64.vmx: perms=C0644 size=2388

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 SCP session complete, closing stdin pipe.

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 Waiting for SSH session to complete.

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 scp stderr (length 39): Sink: C0644 2388 centos-7.2-x86_64.vmx

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 opening new ssh session

2016/10/06 17:37:40 packer: 2016/10/06 17:37:40 starting remote command: vim-cmd vmsvc/reload 947

2016/10/06 17:37:41 packer: 2016/10/06 17:37:41 remote command exited with '0': vim-cmd vmsvc/reload 947

2016/10/06 17:37:41 packer: 2016/10/06 17:37:41 opening new ssh session

2016/10/06 17:37:41 packer: 2016/10/06 17:37:41 starting remote command: vim-cmd vmsvc/power.getstate 947

2016/10/06 17:37:42 packer: 2016/10/06 17:37:42 remote command exited with '0': vim-cmd vmsvc/power.getstate 947

2016/10/06 17:37:42 ui: ==> vmware-iso: Unregistering virtual machine...

2016/10/06 17:37:42 packer: 2016/10/06 17:37:42 opening new ssh session

==> vmware-iso: Unregistering virtual machine...

2016/10/06 17:37:42 packer: 2016/10/06 17:37:42 starting remote command: vim-cmd vmsvc/unregister 947

2016/10/06 17:37:43 packer: 2016/10/06 17:37:43 remote command exited with '0': vim-cmd vmsvc/unregister 947

2016/10/06 17:37:43 ui error: Build 'vmware-iso' errored: lstat zr-centos-7.2-x86_64-vmware: no such file or directory

2016/10/06 17:37:43 Builds completed. Waiting on interrupt barrier...

2016/10/06 17:37:43 machine readable: error-count []string{"1"}

2016/10/06 17:37:43 ui error: 

==> Some builds didn't complete successfully and had errors:

2016/10/06 17:37:43 machine readable: vmware-iso,error []string{"lstat zr-centos-7.2-x86_64-vmware: no such file or directory"}

2016/10/06 17:37:43 ui error: --> vmware-iso: lstat zr-centos-7.2-x86_64-vmware: no such file or directory

2016/10/06 17:37:43 ui: 

==> Builds finished but no artifacts were created.

2016/10/06 17:37:43 waiting for all plugin processes to complete...

Build 'vmware-iso' errored: lstat zr-centos-7.2-x86_64-vmware: no such file or directory


==> Some builds didn't complete successfully and had errors:

--> vmware-iso: lstat zr-centos-7.2-x86_64-vmware: no such file or directory


2016/10/06 18:04:12 ui:     vmware-iso: Detaching ISO from CD-ROM device...

    vmware-iso: Detaching ISO from CD-ROM device...

2016/10/06 18:04:12 ui:     vmware-iso: Disabling VNC server...

    vmware-iso: Disabling VNC server...

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Writing VMX to: /tmp/packer-vmx526502208/centos-7.2-x86_64.vmx

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 opening new ssh session

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Starting remote scp process:  scp -vt /vmfs/volumes/Datastore2/zr1-centos-7.2-x86_64-vmware

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Started SCP session, beginning transfers...

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Copying input data into temporary file so we can read the length

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 [DEBUG] scp: Uploading centos-7.2-x86_64.vmx: perms=C0644 size=2388

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 SCP session complete, closing stdin pipe.

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Waiting for SSH session to complete.

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 scp stderr (length 39): Sink: C0644 2388 centos-7.2-x86_64.vmx

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 opening new ssh session

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 starting remote command: vim-cmd vmsvc/reload 948

2016/10/06 18:04:13 packer: 2016/10/06 18:04:13 remote command exited with '0': vim-cmd vmsvc/reload 948

2016/10/06 18:04:13 packer: 2016/10/06 18:04:13 opening new ssh session

2016/10/06 18:04:13 packer: 2016/10/06 18:04:13 starting remote command: vim-cmd vmsvc/power.getstate 948

2016/10/06 18:04:14 packer: 2016/10/06 18:04:14 remote command exited with '0': vim-cmd vmsvc/power.getstate 948

2016/10/06 18:04:14 ui: ==> vmware-iso: Unregistering virtual machine...

==> vmware-iso: Unregistering virtual machine...

2016/10/06 18:04:14 packer: 2016/10/06 18:04:14 opening new ssh session

2016/10/06 18:04:14 packer: 2016/10/06 18:04:14 starting remote command: vim-cmd vmsvc/unregister 948

2016/10/06 18:04:15 packer: 2016/10/06 18:04:15 remote command exited with '0': vim-cmd vmsvc/unregister 948

2016/10/06 18:04:15 ui: Build 'vmware-iso' finished.

2016/10/06 18:04:15 Builds completed. Waiting on interrupt barrier...

2016/10/06 18:04:15 ui: 

==> Builds finished. The artifacts of successful builds are:

2016/10/06 18:04:15 machine readable: vmware-iso,artifact-count []string{"1"}

Build 'vmware-iso' finished.


==> Builds finished. The artifacts of successful builds are:

2016/10/06 18:04:15 machine readable: vmware-iso,artifact []string{"0", "builder-id", "mitchellh.vmware-esx"}

2016/10/06 18:04:15 machine readable: vmware-iso,artifact []string{"0", "id", "VM"}

2016/10/06 18:04:15 machine readable: vmware-iso,artifact []string{"0", "string", "VM files in directory: zr1-centos-7.2-x86_64-vmware"}

2016/10/06 18:04:15 machine readable: vmware-iso,artifact []string{"0", "files-count", "0"}

2016/10/06 18:04:15 machine readable: vmware-iso,artifact []string{"0", "end"}

2016/10/06 18:04:15 ui: --> vmware-iso: VM files in directory: zr1-centos-7.2-x86_64-vmware

2016/10/06 18:04:15 waiting for all plugin processes to complete...

--> vmware-iso: VM files in directory: zr1-centos-7.2-x86_64-vmware

2016/10/06 18:04:15 /usr/local/bin/packer: plugin process exited

2016/10/06 18:04:15 /usr/local/bin/packer: plugin process exited

2016/10/06 18:04:15 /usr/local/bin/packer: plugin process exited

[newzr@newgw189 bento-master]$ ls -ltr

total 4748

-rw-r--r--  1 newzr newzr   56412 Sep 21 13:44 CHANGELOG.md

-rw-r--r--  1 newzr newzr     119 Sep 21 13:44 Gemfile

-rw-r--r--  1 newzr newzr   10850 Sep 21 13:44 LICENSE

-rw-r--r--  1 newzr newzr    1288 Sep 21 13:44 MAINTAINERS.md

-rw-r--r--  1 newzr newzr     304 Sep 21 13:44 NOTICE.md

-rw-r--r--  1 newzr newzr   11051 Sep 21 13:44 OLD-BOXES.md

-rw-r--r--  1 newzr newzr   22376 Sep 21 13:44 README.md

-rw-r--r--  1 newzr newzr    3165 Sep 21 13:44 Rakefile

-rw-r--r--  1 newzr newzr    1439 Sep 21 13:44 Thorfile

drwxr-xr-x  2 newzr newzr    4096 Sep 21 13:44 archive

drwxr-xr-x  2 newzr newzr    4096 Sep 21 13:44 bin

-rw-r--r--  1 newzr newzr      35 Sep 21 13:44 bootstrap.sh

-rw-r--r--  1 newzr newzr    1486 Sep 21 13:44 build.sh

-rw-r--r--  1 newzr newzr    1068 Sep 21 13:44 buildkite.rb

-rw-r--r--  1 newzr newzr    6038 Sep 21 13:44 centos-5.11-i386.json

-rw-r--r--  1 newzr newzr    6040 Sep 21 13:44 centos-5.11-x86_64.json

-rw-r--r--  1 newzr newzr    6028 Sep 21 13:44 centos-6.8-i386.json

-rw-r--r--  1 newzr newzr    6030 Sep 21 13:44 centos-6.8-x86_64.json

-rw-r--r--  1 newzr newzr    8285 Sep 21 13:44 debian-7.11-amd64.json

-rw-r--r--  1 newzr newzr    8286 Sep 21 13:44 debian-7.11-i386.json

-rw-r--r--  1 newzr newzr    8527 Sep 21 13:44 debian-8.5-amd64.json

-rw-r--r--  1 newzr newzr    8528 Sep 21 13:44 debian-8.5-i386.json

-rw-r--r--  1 newzr newzr    5949 Sep 21 13:44 fedora-23-i386.json

-rw-r--r--  1 newzr newzr    6161 Sep 21 13:44 fedora-23-x86_64.json

-rw-r--r--  1 newzr newzr    5952 Sep 21 13:44 fedora-24-i386.json

-rw-r--r--  1 newzr newzr    6165 Sep 21 13:44 fedora-24-x86_64.json

drwxr-xr-x  4 newzr newzr    4096 Sep 21 13:44 floppy

-rw-r--r--  1 newzr newzr    7959 Sep 21 13:44 freebsd-10.3-amd64.json

-rw-r--r--  1 newzr newzr    7952 Sep 21 13:44 freebsd-10.3-i386.json

-rw-r--r--  1 newzr newzr    8376 Sep 21 13:44 freebsd-9.3-amd64.json

-rw-r--r--  1 newzr newzr    8371 Sep 21 13:44 freebsd-9.3-i386.json

drwxr-xr-x 24 newzr newzr    4096 Sep 21 13:44 http

-rw-r--r--  1 newzr newzr    6589 Sep 21 13:44 macosx-10.10.json

-rw-r--r--  1 newzr newzr    6590 Sep 21 13:44 macosx-10.11.json

-rw-r--r--  1 newzr newzr    6586 Sep 21 13:44 macosx-10.7.json

-rw-r--r--  1 newzr newzr    6586 Sep 21 13:44 macosx-10.8.json

-rw-r--r--  1 newzr newzr    6586 Sep 21 13:44 macosx-10.9.json

-rw-r--r--  1 newzr newzr    8299 Sep 21 13:44 omnios-r151014.json

-rw-r--r--  1 newzr newzr    8299 Sep 21 13:44 omnios-r151018.json

-rw-r--r--  1 newzr newzr    6751 Sep 21 13:44 opensuse-13.2-i386.json

-rw-r--r--  1 newzr newzr    6751 Sep 21 13:44 opensuse-13.2-x86_64.json

-rw-r--r--  1 newzr newzr    6781 Sep 21 13:44 opensuse-leap-42.1-x86_64.json

-rw-r--r--  1 newzr newzr    6003 Sep 21 13:44 oracle-5.11-i386.json

-rw-r--r--  1 newzr newzr    6005 Sep 21 13:44 oracle-5.11-x86_64.json

-rw-r--r--  1 newzr newzr    6038 Sep 21 13:44 oracle-6.7-i386.json

-rw-r--r--  1 newzr newzr    6040 Sep 21 13:44 oracle-6.7-x86_64.json

-rw-r--r--  1 newzr newzr    6040 Sep 21 13:44 oracle-7.2-x86_64.json

-rw-r--r--  1 newzr newzr    6004 Sep 21 13:44 rhel-5.11-i386.json

-rw-r--r--  1 newzr newzr    6003 Sep 21 13:44 rhel-5.11-x86_64.json

-rw-r--r--  1 newzr newzr    6039 Sep 21 13:44 rhel-6.8-i386.json

-rw-r--r--  1 newzr newzr    6038 Sep 21 13:44 rhel-6.8-x86_64.json

-rw-r--r--  1 newzr newzr    6038 Sep 21 13:44 rhel-7.2-x86_64.json

-rw-r--r--  1 newzr newzr    6563 Sep 21 13:44 sles-12-sp1-x86_64.json

-rw-r--r--  1 newzr newzr    6620 Sep 21 13:44 sles-12-x86_64.json

-rw-r--r--  1 newzr newzr    4303 Sep 21 13:44 solaris-10.11-x86.json

-rw-r--r--  1 newzr newzr    6342 Sep 21 13:44 solaris-11-x86.json

-rw-r--r--  1 newzr newzr    9168 Sep 21 13:44 ubuntu-12.04-amd64.json

-rw-r--r--  1 newzr newzr    9170 Sep 21 13:44 ubuntu-12.04-i386.json

-rw-r--r--  1 newzr newzr    9168 Sep 21 13:44 ubuntu-14.04-amd64.json

-rw-r--r--  1 newzr newzr    9170 Sep 21 13:44 ubuntu-14.04-i386.json

-rw-r--r--  1 newzr newzr   10718 Sep 21 13:44 ubuntu-15.10-amd64.json

-rw-r--r--  1 newzr newzr   10724 Sep 21 13:44 ubuntu-15.10-i386.json

-rw-r--r--  1 newzr newzr   10718 Sep 21 13:44 ubuntu-16.04-amd64.json

-rw-r--r--  1 newzr newzr   10726 Sep 21 13:44 ubuntu-16.04-i386.json

drwxr-xr-x  3 newzr newzr    4096 Sep 21 13:44 vagrantfile_templates

-rw-r--r--  1 newzr newzr    2386 Sep 21 13:44 windows-nano-tp3.json

drwxr-xr-x  2 newzr newzr    4096 Sep 21 13:44 packer_cache

-rw-r--r--  1 newzr newzr    6033 Sep 21 13:45 centos-7.2-x86_64.json

-rw-------  1 newzr newzr 2097152 Sep 21 13:45 Redhat_64.vdi

-rw-------  1 newzr newzr 2097152 Sep 21 13:45 RedHat_64.vdi

-rw-r--r--  1 newzr newzr    2829 Sep 21 16:09 virtualbox-centos-7.2-x86_64.json

drwxr-xr-x  2 newzr newzr    4096 Sep 21 16:09 builds

drwxr-xr-x  2 newzr newzr    4096 Sep 21 16:18 packer-centos-7.2-x86_64-virtualbox

-rw-r--r--  1 newzr newzr       0 Sep 21 16:32 build.pwi

-rw-r--r--  1 newzr newzr       0 Sep 21 16:32 build.pwd

-rw-r--r--  1 newzr newzr       0 Sep 21 16:32 build.hwm

-rw-r--r--  1 newzr newzr    2505 Sep 24 16:43 vmware-centos-7.2-x86_64.json

drwxr-xr-x 16 newzr newzr    4096 Sep 28 10:08 scripts

-rw-r--r--  1 newzr newzr    2843 Oct  6 13:34 zr60.json

drwxrwxr-x  2 newzr newzr    4096 Oct  6 17:52 zr1-centos-7.2-x86_64-vmware

-rw-r--r--  1 newzr newzr    2904 Oct  6 17:52 zr60-remote.json

[newzr@newgw189 bento-master]$ cd zr1-centos-7.2-x86_64-vmware/

[newzr@newgw189 zr1-centos-7.2-x86_64-vmware]$ ls


zr60-remote.log
zr60-remote.json

Steven Langlois

unread,
Oct 7, 2016, 4:34:12 PM10/7/16
to Packer
Hoping for a little help here. If I have packer running on machine A and build the VM on a remote ESX server so I am using:

      "remote_host": "emtesx",

      "remote_username": "root",

      "remote_password": "xxxxxx.",

      "remote_type": "esx5",

      "remote_datastore": "Datastore2",


in my builder, where are the artifacts of the build suppose to be when the build is complete? 


The output directory is set to 


      "output_directory": "zr-{{user `template`}}-vmware",


Are the artifacts suppose to be copied to machine A and put in a zr-xxxx-vmware directory or on the ESX Datastore 2.


Right now, they are on ESX Datastore 2 but they are unregistered from the VM so it leaves the VM on the ESX server as orphaned. Is this that way it is supposed to work?


What is Packer doing in this section of the log:


2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 opening new ssh session

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Starting remote scp process:  scp -vt /vmfs/volumes/Datastore2/zr1-centos-7.2-x86_64-vmware

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Started SCP session, beginning transfers...

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 Copying input data into temporary file so we can read the length

2016/10/06 18:04:12 packer: 2016/10/06 18:04:12 [DEBUG] scp: Uploading centos-7.2-x86_64.vmx: perms=C0644 size=2388


Is it trying to copy the artifacts? 


Any help with how this is suppose to work it greatly appreciate. My end goal is an automated build process so do I have to script the copying of the artifacts of machine A and then removing them from the ESX server.


Thank you.


Nick Charlton

unread,
Oct 7, 2016, 5:00:11 PM10/7/16
to Packer
Hi Steven,

This is something I’ve been working on recently and it sounds like we’re trying to achieve the same thing. I think I’ve gotten a bunch further than you have, so hopefully this’ll help:

Re the output directory error: You’ll find that that occurs locally, so if you create a local directory with the same name, it’ll stop happening. These are relevant here:

https://github.com/mitchellh/packer/issues/3087
https://github.com/mitchellh/packer/pull/3050

Those fixes are in master now, so if you compile a copy this will go away.

Re: remote artefacts: The artefacts will stay on the remote (ESXi box). I’ve been adding ""keep_registered": true” to the builder so I can easily boot them back up.

Does this help?


Nick

Steven Langlois

unread,
Oct 7, 2016, 5:12:19 PM10/7/16
to Packer
Hi Nick,

Thank you so much. Yes, this helps a lot. The fact that the local directory was required but then empty was quite confusing so I wasn't sure who it was supposed to work.

Also, thanks for the the tip about keep_registered. I think the default should be to keep the VM registered because dealing with orphaned VMs is a PITA.

Best regards,

Steve

Steven Langlois

unread,
Oct 7, 2016, 5:17:31 PM10/7/16
to Packer
Hi Nick,

A followup question. Are you using "format": "ovf" or some other format? The documentation says you need to install ovftool but do you install it on the ESX server or the machine that is hosting packer?

Thank you,

Steve

Nick Charlton

unread,
Oct 8, 2016, 2:35:58 PM10/8/16
to Packer
Hi Steve,

Yeah, it's a super confusing bug which should hopefully be gone soon.

"keep_registered" defaulting to staying wouldn't fit what the other (more common) usage for Packer is, so I would feel the current default is probably right. I'm currently using it for provisioning specific VMs to duplicate later, but if you're going further than that, I suspect Terraform might be a better fit.

I'm not using ovftool yet and I'm not sure either how to go about installing it on ESXi. A quick search didn't enlighten me either, so I'd be interested to hear how you get on with that.

Nick

Alvaro Miranda Aguilera

unread,
Oct 9, 2016, 2:04:54 PM10/9/16
to packe...@googlegroups.com
Hello

My understanding is the format: ova + ovftool is when you build locally, so at the end of the build which defaults to OVF+VMDK, ovftool is called and create the new OVA file.

When you build remotely on ESXI, the resultant VM is ready to use format OVF+VMDK.

What I have seen is people use ovftool manually in post-provisioner shell-local to invoke ovftool in the local computer, connect to the remote ESXi and perform some action, say create a template from the VM.

However those are separate tasks.

Hope this clarify. If there is still something note clear, and the documentation is not clear, could you highlight what need to be reviewed?

Thanks
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/52eaabab-ae2d-4721-adbd-4dd77a31500d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages