packer should trigger virtualbox with --type headless when the variable 'headless' is set to true.

Created on 7 Sep 2017  ยท  5Comments  ยท  Source: hashicorp/packer

Hello,
The following problem:
We want to trigger automated packer builds on one of our servers. So we don't have an X-Server on that machine. We run our builds with the internal packer variable headless=true. The qemu build works without a problem, but when we trigger the virtualbox build we get the following error:

==> virtualbox-iso: Error starting VM: VBoxManage error: VBoxManage: error: The virtual machine 'packer-virtualbox-iso-1504738600' has terminated unexpectedly during startup with exit code 1 (0x1)                                                                                                                           
==> virtualbox-iso: VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine      

I have traced that bug to this ticket: https://www.virtualbox.org/ticket/7367
So the solution is to trigger the startvm command of virtualbox with type=headless when the headless-variable in packer has been set.

Our packer version is: 1.0.4

buildevirtualbox need-more-info

Most helpful comment

sure: https://github.com/archlinux/arch-boxes/blob/master/vagrant.json
You can test this with this line:

packer-io build -parallel=false -var 'headless=true' -var 'iso_url=https://downloads.archlinux.de/iso/2017.09.01/archlinux-2017.09.01-x86_64.iso' -var 'iso_checksum_url=https://downloads.archlinux.de/iso/2017.09.01/sha1sums.txt' -except=vmware-iso -except=qemu vagrant.json

You have to run this in TTY without X-Server to trigger the bug

All 5 comments

That logic already exists, so I'm surprised this doesn't work for you. Can you please post a json that reproduces the issue as well as a debug log?

sure: https://github.com/archlinux/arch-boxes/blob/master/vagrant.json
You can test this with this line:

packer-io build -parallel=false -var 'headless=true' -var 'iso_url=https://downloads.archlinux.de/iso/2017.09.01/archlinux-2017.09.01-x86_64.iso' -var 'iso_checksum_url=https://downloads.archlinux.de/iso/2017.09.01/sha1sums.txt' -except=vmware-iso -except=qemu vagrant.json

You have to run this in TTY without X-Server to trigger the bug

Please gist a full debug log from PACKER_LOG=1 packer build template.json.

Hello,
nvm. Sorry for the noise. Works now as expected. I forgot loading the virtualbox modules.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings