hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.13k stars 3.33k forks source link

Packer 1.8.4 not working with Virtualbox 7.0.4+ #12118

Open breisig opened 2 years ago

breisig commented 2 years ago

I am building Rocky Linux 9 boot iso images using packer+virtualbox[virtualbox-iso] with a kickstart file and it works great with Virtualbox 6.1.xx, However when running the latest Virtualbox 7.0.4 [and I think all Virtualbox 7.xx versions], it seems during the Rocky Linux installation where it tries to download the kickstart file from 10.0.2.2, it doesn't seem to be able to get the file anymore. It says "curl: (28) Failed to connect to 10.0.2.2 port 8235: Connection timed out"

Reproduction Steps

Upgrade from Virtualbox 6.1.xx to the latest 7.xx

Packer version

packer v1.8.4

OS Version

Windows 11 22H2 Pro

image

afagund commented 2 years ago

Same problem here running packer 1.8.4 and virtualbox Version 7.0.2 r154219 (Qt5.15.3)

hswong3i commented 2 years ago

image

Case similar here: Ubuntu 22.10 host + packer 1.8.4 + VirtualBox 7.0.4 + Debian 11, with error message Failed to retrieve the preconfiguration file.

Working fine with Ubuntu 22.04 host + packer 1.8.4 + VirtualBox 6.1.40 + Debian 11: https://gitlab.com/alvistack/vagrant-debian/-/jobs/3345658507

My packer.json: https://github.com/alvistack/vagrant-debian/blob/a2286d4f/packer/debian-11-virtualbox/packer.json

cedricroijakkers commented 2 years ago

I am having the same problem with Packer 1.8.4 with VirtualBox 7.0.4r154605 on host OS Arch Linux.

As far as I can see, the problem is that the (in my case) Ubuntu 22.04 guest OS does not seem to have network connectivity, and therefore cannot download the autoinstall files from the http directory.

etho201 commented 2 years ago

Same issue here.

I've found a prominent blog that also describes the issue: https://oracle-base.com/blog/2022/11/20/virtualbox-7-0-4-and-vagrant-2-3-3-another-virtualbox-fail/

If I attempt to use Packer, it will fail to find the kickstart file, which it attempts to access over HTTPS. Both cases seem to be network related.

Packer just doesn’t work. It fails getting the HTTP access to the kickstart file.

noroutine commented 1 year ago

hit this when trying to build RHEL9 image on Mac OS 13.0.1 (22A400), packer v1.8.4, vbox 7.0.2 r154219 (Qt5.15.2)

noroutine commented 1 year ago

After some headscratching, have found the (not ideal) workaround.

Go to Tools > Network > NAT Networks Create any network, say NatNetwork with IPv4 prefix of 10.0.2.0/24

Screenshot 2022-12-03 at 23 12 15

While build is spinning up, quickly go to vm settings and switch network adapter from NAT to NAT Network and choose your created NatNetwork

It appears to me there is an issue with virtualbox default 'NAT' networking.

In the end i just ended up putting kickstarter config elsewhere, which luckily worked without issues

Zotteljedi commented 1 year ago

I just had the same issue with a Debian preseed scenario. I noticed that a VM created using the VirtualBox GUI works fine. So I compared the .vbox files and found (among others) this difference:

<NAT localhost-reachable="true"/>

I ended up with adding this section to my virtualbox-iso source configuration:

  vboxmanage = [
    ["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"],
  ]

"Works on my machine."

breisig commented 1 year ago

Interesting,

I enabled it also in my virtualbox-iso on Virtualbox 7.0.4 and it worked. I wonder why this has to be enabled where it didn't in earlier versions?

vboxmanage = [
    ["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"],
  ]
willieseabrook commented 1 year ago

I can confirm this is an issue on packer 1.8.5 with VirtualBox 7.0.6 with Manjaro Sway as the host and arch as the guest trying to use packer build.

The error I was getting was that packer build would stall on: "Using SSH communicator to connect: 127.0.0.1"

Using the solution of Zotteljedi (a comment above) in my arch-template.json file solved the issues:

  vboxmanage = [
    ["modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"],
  ]
kristianheljas commented 1 year ago

I stumbled across this as well and scratched my head for 2 days, since debian installer just ... hanged.

From what I gathered from the #vbox IRC channel: --nat-localhostreachable was introduced in 7.0.0 and set to "off" by default. Can also confirm that setting this to "off" will fix the issue.

I opened an issue in the virtualbox plugin repo, where the fix should be applied, see https://github.com/hashicorp/packer-plugin-virtualbox/issues/104

sbrueseke commented 1 year ago

I encounter this issue when running packer version 1.9.4 on a server where KVM/qemu ins installed. So it looks like this is not related to virtualbox only.

dreibh commented 5 months ago

The problem still occurs with Packer 1.11.0 (from HashiCorp repository) and VirtualBox 7.0.18 (from Oracle repository), tested under Ubuntu 22.04-LTS:

$ apt-show-versions | grep "^virtualbox\|packer"
packer:amd64/jammy 1.11.0-1 uptodate
packer:i386 not installed
virtualbox-7.0:amd64/jammy 7.0.18-162988~Ubuntu~jammy uptodate

The work-around solves the issue, i.e.:

  "vboxmanage": [
    [ "modifyvm", "{{.Name}}", "--nat-localhostreachable1", "on"],
    ...
robertauer commented 5 months ago

Confirmed, this issue still exists with Packer 1.11.0, VirtualBox 7.0.16 on Ubuntu 24.04