Since I’m using Apple Silicon as my daily driver I haven’t been able to use vagrant / virtualbox locally (virtualbox isn’t supported on Apple Silicon and it does not look like there are any plans to add support but there are some potential alternatives in the works - Tart and UTM). I use packer for building custom vagrant boxes that I need for development of custom applications.
Since I can’t run this setup locally I do it on a host that has as a bare metal install of Ubuntu (virtualbox can’t be installed within a VM). Because it’s running remotely I need to set the headless
variable to true
. When running locally virtualbox would automatically pop up the console window so you could follow along on the progress but when running in headless
mode this isn’t an option. This console window can be handy when you’re initially developing your packer configuration files.
Have no fear! There is still a way to get console access when running packer / vagrant / virtualbox remotely and headless. If you have ever watched the packer log file as it’s running you may have noticed the following:
==> virtualbox-iso.base: Starting the virtual machine...
virtualbox-iso.base: The VM will be run headless, without a GUI. If you want to
virtualbox-iso.base: view the screen of the VM, connect via VRDP without a password to
virtualbox-iso.base: rdp://127.0.0.1:5911
If you were to try to connect without modifying your packer config you would get connection refused. But if you add the following line to your packer config it will work:
vboxmanage = [
[ "modifyvm", "{{.Name}}", "--vrdeaddress", "0.0.0.0" ]
]
The packer log will still look the exact same as it previously showed rdp://127.0.0.1:5911
but it will work if you attempt to connect remotely (it may prompt for a password but just leave blank and continue). Once I know my packer config is in a good place I will remove this config item.