VBoxManage: error: Could not find a controller named 'IDE Controller'
Overview of the Issue
I came across this issue when using Ubuntu's daily cloud images with the virtualbox-ovf builder. After importing the OVA, the plugin tries to attach the iso generated from the cloud-init data in cd_content. It looks for an ide controller named IDE Controller, but finds none; however a controller IDE exists. I suspect that this may be related to the VirtualBox version (6.1.30)?
I solved this issue locally by adding a vboxmanage_pre field to the plugin, which runs just after the VM is created (or OVF imported).
Adding the following lines to the problem buildfile below would fix the issue. If this is solution works, I can submit a PR. If not, I'm open to other ideas/solutions.
"vboxmanage_pre": [[ "storagectl", "{{.Name}}", "--name", "IDE", "--rename", "IDE Controller" ]],
"vboxmanage_post": [[ "storagectl", "{{.Name}}", "--name", "IDE Controller", "--rename", "IDE" ]],
Reproduction Steps
Using the example build file below:
PACKER_LOG=1 packer build example.json
Plugin and Packer version
Packer v1.7.8
Simplified Packer Buildfile
example.json
{
"builders": [{
"type": "virtualbox-ovf",
"vm_name": "vboxmanage-pre.example",
"communicator": "none",
"virtualbox_version_file": "",
"source_path": "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.ova",
"checksum": "file:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS",
"guest_additions_mode": "disable",
"cd_label": "cidata",
"cd_content": {
"meta-data": "local-hostname: changeme",
"user-data": ""
},
"boot_wait": "2m",
"keep_registered": "false",
"skip_export": "true"
}]
}
Operating system and Environment details
Oracle VM VirtualBox VM Selector v6.1.30
Log Fragments and crash.log files
...
2022/01/17 15:25:53 packer-plugin-virtualbox plugin: 2022/01/17 15:25:53 Not attaching guest additions since we're uploading.
2022/01/17 15:25:53 packer-plugin-virtualbox plugin: 2022/01/17 15:25:53 Executing VBoxManage: []string{"storageattach", "vboxmanage-pre.example", "--storagectl", "IDE Controller", "--port", "1", "--device", "1", "--type", "dvddrive", "--medium", "/tmp/packer324561340.iso"}
virtualbox-ovf: Mounting cd_files ISO...
2022/01/17 15:25:53 packer-plugin-virtualbox plugin: 2022/01/17 15:25:53 stdout:
2022/01/17 15:25:53 packer-plugin-virtualbox plugin: 2022/01/17 15:25:53 stderr: VBoxManage: error: Could not find a controller named 'IDE Controller'
==> virtualbox-ovf: Error attaching ISO: VBoxManage error: VBoxManage: error: Could not find a controller named 'IDE Controller'
==> virtualbox-ovf: Deregistering and deleting imported VM...
...
I have tried VirtualBox 6.1 on macOS and Ubuntu has the same issue. Maybe VirtualBox 6.1 changes some default naming policy?
Updated: VirtualBox 6.0 has the same issue
still an issue on Virtualbox 7.x
Unfortunately, vboxmanage_pre seems to not be available anymore in the config.
vboxmanage seems to be the way to pass vboxmanage commands before the vm starts but commands will be run after packer trying to attach CD.
So workaround seems to be no longer working :(