hashicorp / packer-plugin-virtualbox

Packer plugin for VritualBox Builder
https://www.packer.io/docs/builders/virtualbox
Mozilla Public License 2.0
23 stars 36 forks source link

virtualbox-ovf builder is not compatible with Ubuntu 22.04 cloud image mounting cd_files #108

Open hc-github-team-packer opened 1 year ago

hc-github-team-packer commented 1 year ago

This issue was originally opened by @Jamie- in https://github.com/hashicorp/packer/issues/12340 and has been migrated to this repository. The original issue description is below.


Community Note

Overview of the Issue

Packer's virtualbox-ovf is not compatible with the latest (today) Ubuntu 22.04 Jammy cloud image when mounting the cd_files ISO file. When the Ubuntu cloud image is imported into VirtualBox, the IDE controller name is just "IDE" and not "IDE Controller" which is hardcoded in the packer virtualbox-ovf plugin.

If I inspect the imported Ubuntu OVA with vboxmanage list vms -l you can see the storage controller name is just "IDE":

Storage Controller Name (0):            IDE
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on

Whereas packer hardcodes the storage controller name to "IDE Controller", which I think is here: https://github.com/hashicorp/packer-plugin-virtualbox/blob/main/builder/virtualbox/common/step_attach_isos.go#L107

I tried adding a vboxmanage command to rename the controller but the CD image ISO is mounted in an earlier step to vboxmanage so this doesn't help:

  vboxmanage = [
    ["storagectl", "{{ .Name }}", "--name", "IDE", "--rename", "IDE Controller"],
  ]

Reproduction Steps

Grab the template below, create a directory vm_data, create any random file in it, and start a packer build

PACKER_LOG=1 packer build ubuntu.pkr.hcl

Packer version

$ packer version
Packer v1.8.6

Simplified Packer Template

source "virtualbox-ovf" "jammy" {
  vm_name = "jammy"
  source_path = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.ova"
  checksum = "sha256:80decd92b39aad995bb1a7a01ae64680514f33d5ef4e117c5193f0eab376294c"
  headless = true
  cd_files = ["vm_data/*"]
  cd_label = "cidata"
  ssh_port = 22
  ssh_timeout = "30m"
  ssh_username = "ubuntu"
  shutdown_command = "sudo -S -E shutdown -P now"
}

build {
  sources = [
    "source.virtualbox-ovf.jammy"]
  provisioner "shell" {
    inline = ["echo foo"]
  }
 }

Operating system and Environment details

Host OS is Ubuntu 22.04 more details below:

$ vboxmanage -v
6.1.38_Ubuntur153438
$ lsb_release -d
Description:    Ubuntu 20.04.6 LTS
$ uname -r
5.4.0-135-generic

Log Fragments and crash.log files

==> virtualbox-ovf.jammy: Mounting ISOs...
    virtualbox-ovf.jammy: Mounting cd_files ISO...
2023/04/04 16:13:09 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"storageattach", "jammy", "--storagectl", "IDE Controller", "--port", "1", "--device", "1", "--type", "dvddrive", "--medium", "/tmp/packer583214647.iso"}
2023/04/04 16:13:09 packer-builder-virtualbox-ovf plugin: stdout:
2023/04/04 16:13:09 packer-builder-virtualbox-ovf plugin: stderr: VBoxManage: error: Could not find a controller named 'IDE Controller'
==> virtualbox-ovf.jammy: Error attaching ISO: VBoxManage error: VBoxManage: error: Could not find a controller named 'IDE Controller'
==> virtualbox-ovf.jammy: Error attaching ISO: VBoxManage error: VBoxManage: error: Could not find a controller named 'IDE Controller'
==> virtualbox-ovf.jammy: Step "StepAttachISOs" failed

Set the env var PACKER_LOG=1 for maximum log detail.

Marc3001 commented 7 months ago

Seems to be an issue since a while as this issue is the same as this one https://github.com/hashicorp/packer-plugin-virtualbox/issues/56