Vsphere-iso does nothing useful when communicator is none

I wanted to discuss this before opening a GitHub issue.

I’m using vsphere-iso to build a VM template behind a firewall. There are no provisioners to need WinRM, SSH, nor to test either. Neither will be opened from the firewall’s external interface. The script(s) inserted via floppy-attachment do everything necessary. With WinRM and no provisioners:

$ time packer build -var-file=./01-packer/private.json -var-file=./01-packer/dev.json ./01-packer/W2019DCE.json
vsphere-iso: output will be in this color.

==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mounting ISO images...
==> vsphere-iso: Adding configuration parameters...
==> vsphere-iso: Creating floppy disk...
    vsphere-iso: Copying files flatly from floppy_files
    vsphere-iso: Copying directory: ./01-packer/setup/
    vsphere-iso: Adding file: 01-packer/setup/autounattend.xml
    vsphere-iso: Adding file: 01-packer/setup/setup.ps1
    vsphere-iso: Copying file: ./scripts/vmtools.cmd
    vsphere-iso: Done copying files from floppy_files
    vsphere-iso: Collecting paths from floppy_dirs
    vsphere-iso: Resulting paths from floppy_dirs : [./01-packer/drivers]
    vsphere-iso: Recursively copying : ./01-packer/drivers
    vsphere-iso: Done copying paths from floppy_dirs
==> vsphere-iso: Uploading created floppy image
==> vsphere-iso: Adding generated Floppy...
==> vsphere-iso: Set boot order temporary...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting for IP...
==> vsphere-iso: IP address: 192.168.0.2
==> vsphere-iso: Using winrm communicator to connect: 192.168.0.2
==> vsphere-iso: Waiting for WinRM to become available...
==> vsphere-iso: Timeout waiting for WinRM.
==> vsphere-iso: Clear boot order...
==> vsphere-iso: Power off VM...
==> vsphere-iso: Deleting Floppy image ...
==> vsphere-iso: Destroying VM...
Build 'vsphere-iso' errored after 37 minutes 17 seconds: Timeout waiting for WinRM.

==> Wait completed after 37 minutes 17 seconds

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso: Timeout waiting for WinRM.

==> Builds finished but no artifacts were created.

real    37m17.838s
user    0m1.851s
sys     0m2.178s
$

With communicator set to none:

$ time packer build -force -var-file=./01-packer/private.json -var-file=./01-packer/dev.json ./01-packer/W2019DCE.json
vsphere-iso: output will be in this color.

==> vsphere-iso: the vm/template Templates/W2019DCE already exists, but deleting it due to -force flag
==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mounting ISO images...
==> vsphere-iso: Adding configuration parameters...
==> vsphere-iso: Eject CD-ROM drives...
Build 'vsphere-iso' finished after 5 seconds 701 milliseconds.

==> Wait completed after 5 seconds 701 milliseconds

==> Builds finished. The artifacts of successful builds are:
--> vsphere-iso: W2019DCE

real    0m6.215s
user    0m0.390s
sys     0m0.109s
$

Looked at the code and there’s an if statement that skips all the useful stuff when the communicator is “none”. Definitely open a feature request.

1 Like

Would you mind linking the line that indicates this? I’m not sure where to look and I’d like to link it directly in the new issue.

Here you go: https://github.com/hashicorp/packer/blob/master/builder/vsphere/iso/builder.go#L80
This is where the vsphere-iso skips the steps when the communicator is none.

1 Like

Yes! Thank you @sylviamoss and @SwampDragons!!

Did another quick search for an existing issue but didn’t find one.

Created this issue: