Code Monkey home page Code Monkey logo

packer-plugin-virtualbox's Introduction

Packer Plugin Virtualbox

The Virtualbox multi-component plugin can be used with HashiCorp Packer to create custom images. For the full list of available features for this plugin see docs.

Installation

Using pre-built releases

Using the packer init command

Starting from version 1.7, Packer supports a new packer init command allowing automatic installation of Packer plugins. Read the Packer documentation for more information.

To install this plugin, copy and paste this code into your Packer configuration . Then, run packer init.

packer {
  required_plugins {
    virtualbox = {
      version = ">= 1.0.5"
      source  = "github.com/hashicorp/virtualbox"
    }
  }
}

Manual installation

You can find pre-built binary releases of the plugin here. Once you have downloaded the latest archive corresponding to your target OS, uncompress it to retrieve the plugin binary file corresponding to your platform. To install the plugin, please follow the Packer documentation on installing a plugin.

From Sources

If you prefer to build the plugin from sources, clone the GitHub repository locally and run the command go build from the root directory. Upon successful compilation, a packer-plugin-virtualbox plugin binary file can be found in the root directory. To install the compiled plugin, please follow the official Packer documentation on installing a plugin.

Configuration

For more information on how to configure the plugin, please read the documentation located in the docs/ directory.

Contributing

  • If you think you've found a bug in the code or you have a question regarding the usage of this software, please reach out to us by opening an issue in this GitHub repository.
  • Contributions to this project are welcome: if you want to add a feature or a fix a bug, please do so by opening a Pull Request in this GitHub repository. In case of feature contribution, we kindly ask you to open an issue to discuss it beforehand.

packer-plugin-virtualbox's People

Contributors

arizvisa avatar azr avatar bdon avatar benlangfeld avatar benphegan avatar cbednarski avatar chrismarget avatar crunk1 avatar dependabot[bot] avatar dragon788 avatar dreibh avatar edwardmlyte avatar jescalan avatar lbajolet-hashicorp avatar markpeek avatar masteinhauser avatar mcandre avatar mitchellh avatar mwhooker avatar nywilken avatar rasa avatar rickard-von-essen avatar sethvargo avatar smerrill avatar stephen-fox avatar swampdragons avatar sylviamoss avatar taliesins avatar tmeckel avatar upodroid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-virtualbox's Issues

Building virtualbox-iso within nested virtualization does not type the boot command

This issue was originally opened by @blaargh in hashicorp/packer#11744 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

In our toolchain we want to build packer vm's from within a virtual machine. Nested VT-X is working correctly. When using packer build to build Ubuntu 22.04 via virtualbox-iso, the boot command is not being typed.

Reproduction Steps

  1. Get a Ubuntu vm running
  2. Install virtualbox + packer
  3. Build packer with the the template below

Packer version

1.8.0

Simplified Packer Template

https://gist.github.com/blaargh/eddca388c44099785e899edb67f28903

Operating system and Environment details

Ubuntu 22.04 in virtual machine hosted on ESXi 6.7

Log Fragments and crash.log files

2022/05/02 10:06:58 packer-builder-virtualbox-iso plugin: stdout: Waiting for VM "Ubuntu-Desktop-22.04" to power on...
2022/05/02 10:06:58 packer-builder-virtualbox-iso plugin: VM "Ubuntu-Desktop-22.04" has been successfully started.
2022/05/02 10:06:58 packer-builder-virtualbox-iso plugin: stderr:
==> virtualbox-iso: Waiting 4s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Using SSH communicator to connect: 127.0.0.1
==> virtualbox-iso: Waiting for SSH to become available...
2022/05/02 10:07:06 packer-builder-virtualbox-iso plugin: [INFO] Waiting for SSH, up to timeout: 2h46m40s

Nothing is crashing, the boot command just instantly moves on to the SSH command

Allow to download files in ovf/ova builder

This issue was originally opened by @azr as hashicorp/packer#7609. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Currently, the virtualbox-ovf builder can only use local files.

I think we could allow to download files for the ovf/ova builder.

  • For ova files we could allow downloads simply.
  • For ovf files & using the go-getter we could allow archives downloads, we could reference the ovf file in there ? By for example forcing users to name the files in the archive in a specific manner. No sure if files in there are using a relative path & etc ?

Previous issues: hashicorp/packer#1195 hashicorp/packer#3982

virtualbox-iso fails with `Unknown option: --nested-hw-virt`

This issue was originally opened by @jaymzh as hashicorp/packer#10853. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

packer 1.7 assumes a new option called --nested-hw-virt which doesn't exist on VirtualBox 5

Reproduction Steps

try to build a vbox VM using packer 1.7 watch it fail:

VBoxManage: error: Unknown option: --nested-hw-virt

Packer version

1.7.1

Simplified Packer Buildfile

The contents literally don't matter, it fails as soon as it tries to create the vm

Operating system and Environment details

Ubuntu 18.04

Log Fragments and crash.log files

2021/03/31 17:50:10 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-virtualbox-iso-1617238193", "--nested-hw-virt", "off"}
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: stdout:
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: stderr: Oracle VM VirtualBox Command Line Management Interface Version 5.2.42_Ubuntu
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: (C) 2005-2020 Oracle Corporation
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: All rights reserved.
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: 
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: Usage:
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: 
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: VBoxManage modifyvm         <uuid|vmname>
...
2021/03/31 17:50:11 packer-builder-virtualbox-iso plugin: VBoxManage: error: Unknown option: --nested-hw-virt

Virtual Box with multiple Nics failed to locate the NAT network

This issue was originally opened by @bax99 as hashicorp/packer#10379. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Hi there,

When installing Kali Linux 2004 with preseed.cfg and having packer configured with only the NAT network interface on VirtualBox, everything is fine.

However, in my case, I need 3 network interfaces to be configured. But with more than one interface, the packer build gets stuck on "Waiting for SSH to become available". If I open the GUI Virtual Machine and log on, I only see 1 Network Interfaces available under Kali Linux, even if three are configured in the json file.

part of the Json file

  "builders": [
    {
      "type": "virtualbox-iso",
      "boot_command": [
        "<esc><wait>",
        "/install.amd/vmlinuz<wait>",
        " auto<wait>",
        " console-setup/ask_detect=false<wait>",
        " console-setup/layoutcode=us<wait>",
        " console-setup/modelcode=pc105<wait>",
        " debconf/frontend=noninteractive<wait>",
        " debian-installer=en_US<wait>",
        " fb=false<wait>",
        " initrd=/install.amd/initrd.gz<wait>",
        " kbd-chooser/method=us<wait>",
        " console-keymaps-at/keymap=fr-ch<wait>",
        " keyboard-configuration/xkb-keymap=fr-ch<wait>",
        " keyboard-configuration/layout=Swiss french<wait>",
        " keyboard-configuration/variant=Swiss french<wait>",
        " locale=fr_CH<wait>",
        " netcfg/get_domain=hevs<wait>",
        " netcfg/get_hostname=kali<wait>",
        " grub-installer/bootdev=/dev/sda<wait>",
        " noapic<wait>",
		" interface=enp0s3<wait>",
        " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg auto=true priority=critical",
        " -- <wait>",
        "<enter><wait>"
      ],
      "boot_wait": "10s",
      "disk_size": "{{user `disk_size`}}",
      "hard_drive_interface": "sata",	  
      "iso_interface": "sata",
      "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
      "virtualbox_version_file": ".vbox_version",
      "guest_os_type": "Debian_64",
      "headless": "{{ user `headless` }}",
      "http_directory": "{{user `http_directory`}}",
	  "iso_checksum": "{{user `iso_checksum`}}",
      "iso_url": "{{user `iso_url`}}",	  
	  "memory": "{{ user `memory` }}",
	  "vboxmanage": [
        ["storagectl", "{{.Name}}", "--name", "IDE Controller", "--remove"],
        ["modifyvm", "{{.Name}}", "--vrde", "off"],
        ["modifyvm", "{{.Name}}", "--graphicscontroller", "vmsvga"],
        ["modifyvm", "{{.Name}}", "--vram", "128"],
        ["modifyvm", "{{.Name}}", "--accelerate3d", "off"],
        ["modifyvm", "{{.Name}}", "--usb", "on"],
        ["modifyvm", "{{.Name}}", "--mouse", "usbtablet"],
        ["modifyvm", "{{.Name}}", "--audio", "none"],
        ["modifyvm", "{{.Name}}", "--nictype1", "82540EM"],
        ["modifyvm", "{{.Name}}", "--nictype2", "82540EM"],
        ["modifyvm", "{{.Name}}", "--nictype3", "82540EM"],
        ["modifyvm", "{{.Name}}", "--nictype4", "82540EM"],
		["modifyvm", "{{.Name}}", "--clipboard", "bidirectional"],            
        ["modifyvm", "{{.Name}}", "--draganddrop", "bidirectional"],
		["modifyvm", "{{.Name}}", "--nic1", "nat"],
		["modifyvm", "{{.Name}}", "--natnet1", "default"],		
		["modifyvm", "{{.Name}}", "--nic2", "intnet"],
		["modifyvm", "{{.Name}}", "--intnet1", "intnet"],
		["modifyvm", "{{.Name}}", "--nic3", "natnetwork"]
      ],
      "cpus": "{{ user `cpus` }}",	  
      "ssh_username": "adminhevs",
      "ssh_password": "************",
      "ssh_port": 22,
      "ssh_wait_timeout": "10000s",
      "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
      "vm_name": "{{ user `template` }}"
    }
  ],
  "post-processors": [
    {
	"type": "vagrant",
    "output": "builds/{{user `box_basename`}}.{{.Provider}}.box"      
    }
  ],

Kali nics output

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:b2:a1:ae brd ff:ff:ff:ff:ff:ff

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:98:9c:82 brd ff:ff:ff:ff:ff:ff

4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:b9:8c:a3 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.35/24 brd 10.0.2.255 scope global dynamic noprefixroute eth2

As shown, eth0 did not get any IP from nat, neither eth1 from intnet. I can set manually IPs with nmcli, but it is not what I expect.

How can we have multiple NICS in the json file and be sure the first one will be taken into account by packer?

Regards

If guest_additions_mode is attach and device gets lower "ID" on the IDE/SATA bus than ISO, VM fails to boot

Overview of the Issue

Trying to create a Windows 10 VM fails with "FATAL: Could not read from the boot medium! System halted." When looking at the hardware configuration in the Virtualbox UI, it appears the VboxAdditions ISO gets added with a lower ID than the Windows ISO which results in a higher "boot priority" in the DVD category, and so Virtualbox tries to boot from a non-OS ISO and fails, hanging the build.

Switching the type to upload allows it to proceed but takes FOREVER and I've had it intermittently fail for no apparent reason.

I wondered if perhaps setting the tools interface to IDE could work around the issue, or enabling EFI boot instead. I tried both, and it turns out the "fix" is to set the iso_interface to ide and leave the guest_additions_interface as the default (which the docs say is ide, but actually appears to be sata), because IDE apparently gets priority over sata in the boot order evaluation so the Windows ISO boots successfully. This fix also allows EFI to boot properly, where without the workaround you got a slightly less scary EFI prompt instead of the FATAL error message, but if you watched closely, it does actually prompt to "press any key to boot from DVD" where for non-EFI aka BIOS mode you never get that prompt, but interacting with the VM to launch the boot defeats the purpose of Packer's automated process.

Recorded this issue and this workaround in the chef/bento repository I was using when I discovered the issue.
chef/bento#1370

Reproduction Steps

git clone https://github.com/chef/bento chef-bento-packer-templates
cd chef-bento-packer-templates/packer_templates/windows
packer build --only virtualbox-iso windows-10.json

Functional workaround

https://github.com/chef/bento/blob/252830cfe3a38ed5ba217464c1209625b9a3691c/packer_templates/windows/windows-10.json#L32-L40

Changed
iso_interface: ide

Added
guest_additions_interface: sata
It appears that the guest additions gets added as a "secondary device" if left to the default IDE, whether that is an additional IDE bus or just as a slave while the OS ISO is master, it fails to boot in EFI mode but oddly not BIOS mode because it is "port 0" and the OS ISO is "port 1" and Virtualbox's BIOS/EFI implementation doesn't attempt additional devices automatically (or in EFI requires a user keypress).

Plugin and Packer version

1.7.4

Simplified Packer Buildfile

https://github.com/chef/bento/blob/252830cfe3a38ed5ba217464c1209625b9a3691c/packer_templates/windows/windows-10.json

Operating system and Environment details

macOS 11.5.1 host
Virtualbox 6.1.26

Log Fragments and crash.log files

BIOS with guest as IDE and OS ISO as ide
Succeeds (usually)

OS ISO as sata, guest additions as sata, FAILS.
image

OS ISO as sata, guest additions as default IDE FAILS.
Screen Shot 2021-09-02 at 10 59 29 AM

EFI with guest as IDE and OS ISO as ide or sata, FAILS.
Screen Shot 2021-09-02 at 10 53 05 AM

Error when using .VHD as boot device

Overview of the Issue

When using a .vhd as the iso_url (as stated possible in the documentation, VirtualBox returns the error Error attaching ISO: VBoxManage error: VBoxManage.exe: error: The medium '<path/to/vhd>' can't be used as the requested device type (DVD, detected HDD).

Reproduction Steps

Put a .VHD file locaiton as the iso_url and run packer.

Plugin and Packer version

From packer version:
Packer v1.10.0

From packer plugins installed:

C:\Users\<Username>\AppData\Roaming\packer.d\plugins\github.com\hashicorp\ansible\packer-plugin-ansible_v1.1.0_x5.0_windows_amd64.exe
C:\Users\<Username>\AppData\Roaming\packer.d\plugins\github.com\hashicorp\hyperv\packer-plugin-hyperv_v1.1.2_x5.0_windows_amd64.exe
C:\Users\<Username>\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.1.1_x5.0_windows_amd64.exe
C:\Users\<Username>\AppData\Roaming\packer.d\plugins\github.com\hashicorp\virtualbox\packer-plugin-virtualbox_v1.0.5_x5.0_windows_amd64.exe
C:\Users\<Username>\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vmware\packer-plugin-vmware_v1.0.11_x5.0_windows_amd64.exe

Simplified Packer Buildfile

source "virtualbox-iso" "virtualbox" {
  boot_command              = ["a<wait>a<wait>a"]
  boot_wait                 = "-1s"
  cd_files                  = ["./installers"]
  cpus                      = "4"
  disk_size                 = "50000"
  headless                  = "true"
  iso_checksum              = "none"
  iso_url                   = "$<path/to/vhd>"
  memory                    = "4096"
  output_directory          = "./output"
  shutdown_command          = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
  guest_os_type             = "Windows10_64"
  vm_name                   = "${var.vm_name}"
}

build {
  sources = ["source.hyperv-iso.hyperv", "source.virtualbox-iso.virtualbox", "source.vmware-iso.vmware"]
  provisioner "breakpoint" {
    name = "debug"
  }
}

Operating system and Environment details

Windows 10 amd64, running from Powershell.

Log Fragments and crash.log files

Link to Packer log gist

Note

When using VirtualBox GUI, I can put the .vhd as a hard drive and run my VM normally, I just don't understand how to do the same with packer.

cd_content is not generating an ISO

This issue was originally opened by @ctberthiaume in hashicorp/packer#11258 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

I'd like to use cd_content with templatefile to inject templated content during build, specifically to template out user-data and meta-data files for an Ubuntu autoinstall in a Virtualbox VM. The autoinstall works OK when I specify the user-data and meta-data files with cd_files, but if I switch to cd_content no CD ISO is created. Though not included in this example, I also unsuccessfully tried simply using file() rather than templatefile.

Reproduction Steps

Create these autoinstall files:

user-data.pkrtpl

#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: en
  identity:
    hostname: ubuntu-server-tpl-${x}
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
  ssh:
    allow-pw: yes
    install-server: yes

user-data

#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: en
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
  ssh:
    allow-pw: yes
    install-server: yes

meta-data (empty)

And this Packer Buildfile

virtualbox-cd-content-test.pkr.hcl

source "virtualbox-iso" "cd-content-test" {
  guest_os_type    = "Ubuntu_64"
  headless         = false
  iso_url          = "https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso"
  iso_checksum     = "sha256:f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
  ssh_username     = "ubuntu"
  ssh_password     = "ubuntu"
  ssh_handshake_attempts = "20"
  shutdown_command = "echo 'ubuntu' | sudo -S shutdown -P now"
  cd_label = "cidata"
  // cd_files = ["meta-data", "user-data"]
  cd_content = {
    "user-data" = templatefile("user-data.pkrtpl", { x = "foo" })
    "meta-data" = ""
  }
  boot_wait = "5s"
  boot_command = [
    "<enter><enter><f6><esc><wait>",
    "linux /casper/vmlinuz autoinstall<enter><wait>",
  ]
  cpus = 1
  memory = 1024
  vboxmanage = [
    ["modifyvm", "{{.Name}}", "--memory", "1024"],
    ["modifyvm", "{{.Name}}", "--cpus", "1"],
  ]
  format = "ova"
}

build {
  sources = [
    "source.virtualbox-iso.cd-content-test"
  ]
}

Run PACKER_LOG=1 PACKER_LOG_PATH=packer.log packer build virtualbox-cd-content-test.pkr.hcl. The install will fail to find a cloud-config file and stall when asking for a language. The log shows that "No CD files specified. CD disk will not be made." on line 50.

Uncomment the cd_files = ["meta-data", "user-data"] line and comment out the cd_content block, then run the same test again and the install will complete as expected with no interaction necessary. The log shows "Wrote 316 bytes to user-data" on line 54.

Packer version

Packer v1.7.4

Simplified Packer Buildfile

See "Reproduction Steps" above.

Operating system and Environment details

Host OS: MacOS 11.5.2

Virtualbox version: 6.1.26 r145957

Log Fragments and crash.log files

VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports

This issue was originally opened by @Neudrino in hashicorp/packer#12008 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Overview of the Issue

Packer won't build a Virtualbox VM on an ISO image. Error is

==> virtualbox-iso: Error starting VM: retry count exhausted. Last err: VBoxManage error: VBoxManage: error: The machine 'packer-virtualbox-iso-1663686568' is already locked by a session (or being locked or unlocked)
==> virtualbox-iso: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
==> virtualbox-iso: VBoxManage: error: Context: "LaunchVMProcess(a->session, sessionType.raw(), ComSafeArrayAsInParam(aBstrEnv), progress.asOutParam())" at line 727 of file VBoxManageMisc.cpp

Reproduction Steps

Packer version

Packer v1.8.3

Simplified Packer Template

Operating system and Environment details

  • Github Runner macos-12

Log Fragments and crash.log files

Exported EFI VM's do not include relevant NVRAM files

Overview of the Issue

Sometimes when running EFI VM's NVRAM files can be created, at the moment these get cleaned up when the VM is deleted after Packer has exported it, however these may be necessary for the VM to boot as the resulting OVF file will reference them:

<BIOS>
        <IOAPIC enabled="true"/>
        <NVRAM path="/Users/steve.brown/Documents/Repos/Personal/os-provisioning/.build/output/macOS_11/vbox/macOS11-base/macOS11-base.nvram"/>
        <SmbiosUuidLittleEndian enabled="true"/>
 </BIOS>

Unfortunately Virtualbox doesn't offer a way to change the NVRAM location at export time natively, perhaps it could be achieved with an API call?

In my production environment I am using CI/CD to copy the NVRAM file to the Packer output directory and then edit the XML of the resulting OVF file to change the location of the NVRAM file, though it's my belief Packer should handle this natively.

At the moment this only seems to affect macOS, but I should imagine as more things make use of NVRAM files this will be more of an issue.

Reproduction Steps

Build an image that uses EFI firmware and stores NVRAM output (at the moment this appears to be just macOS)
Import the OVF file
It will be un-bootable until you update the location of the NVRAM file

Plugin and Packer version

โฏ packer version
Packer v1.7.8

Simplified Packer Buildfile

https://gist.github.com/shoddyguard/01f726a357d87fa873eb0f92d7b6ee47

Operating system and Environment details

macOS 12.1 host OS and macOS 11/12 VM

Log Fragments and crash.log files

N/A

virtualbox features

This issue was originally opened by @gamethis as hashicorp/packer#9312. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Feature Description

I would like to see 3 items added to the virtualbox builder.
All of this can technically be done with the vboxmanage feature but would be nice so I don't constantly have to look up teh docs for what the strings are.

  1. vram amount of video ram for vm. usefull for my boxes that need more than the defaults.
  2. clipboard so I can enable or disable copy items between host and vm
  3. copypaste so I can enable or disable copy text between vm and host.

Use Case(sup.)

I primarily use this for my vagrant boxes.
But would enable easy setup and transfer of items I need while cleaning up the form in packer.

Issues with Packer building across subnet. PfSense

This issue was originally opened by @Iluvitari as hashicorp/packer#8844. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Hi,

I am basically using packer to deploy jumpboxes in a lab environment.
The lab environment:

  • My local laptop with 1 physical interface and 1 virtual interface created by virtual box with ip address of 192.168.56.2

  • My PfSense box built on virtual box with wan set to communicate with my physical interface for internet and then it has a lan adapter. These are "nic1" "bridged adapter" and "nic2" "host-only adapter". The host only adapter is set to have a subnet of 192.168.56.1/24. So my virtual interface is on this subnet.

  • I have an AD Windows server 2016 box for DHCP, DNS and AD with ip address of 192.168.56.3

So with this my default gateway is 192.168.56.1 and my dhcp/dns should be being provided by 192.168.56.4. I have currently disabled firewalls on the AD server and I have also enabled Any any firewall rules on wan and nat for the pfsense router. SO anything should be able to come through my pfsense in theory.

My issue:
I am able to build a virtual machine with packer that lies on the subnet. BUT winRM is unable to communicate at all. Even though my local machine is sitting on the same subnet. How do I fix this?

Is it because its running of the virtual subnet? Am I able to make winrm talk through the virtual interface?

When I run log I get this message:
connection error: unknown error Post https://127.0.0.1:4327/wsman: dial tcp 127.0.0.1:4327: connectex: No connection could be made because the target machine actively refused it.

I have attatched my log file:
packerlog3.txt

Typo in "about" section of the repository

Overview of the Issue

There is a trivial typo in the "about" section of the repository.

Packer plugin for **VritualBox** Builder
-->
Packer plugin for **VirtualBox** Builder

Export Image is to small 74KB should be ca 400MB

This issue was originally opened by @feckert as hashicorp/packer#7965. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Environment:

  • Packer version from 1.4.2
  • debian 9 X86_64 on native (development)
  • debian 9 X86_64 on VMware (CI/CD)

Development host:
I am building opnsense version 19.07 on my host system with packer. Every think works as expected. Build is successful and the exported image could be load with virtualbox.

Export log on the Development host build:
https://gist.github.com/feckert/982801ea36cd73dd149c8015ed072b6c

Gitlab CI/CD:
With gitlab CI/CD I am building my releases. The build is also successful, but the exported image is too small ! Its only 74KB big. If I open this with the vi editor I see only the ova content. NO VMDK.

I am using this build system for debian appliances as well and every thing works as expected. The images are OK. So my CI/CD works. Only for the opnsense (BSD) it does not!

The following line does appear on my devleopment host but not on the Gitlab CI/CD system. I do not know what the output means!

2019/08/09 14:37:35 Builds completed. Waiting on interrupt barrier...

That is the only difference what I can see

Export log on the Gitlab CI/CD build on a gitlab-runner:
https://gist.github.com/feckert/09cc0682fa5ecdfbe62e96e45a40fe18

Missing support for floppy_content

Overview of the Issue

The current VirtualBox ISO Builder docs mention a floppy_content setting that can be used to add content to a floppy disk. This setting is currently not implemented in the plugin. I believe it applies to all builders, not just the ISO.

Reproduction Steps

Use a VirtualBox builder and set the floppy_content setting:

floppy_content = {
  "user-data" ="foo"
}

Observe the following after running PACKER_LOG=1 packer build:

packer-builder-virtualbox-iso plugin: No floppy disk, not attaching.

Plugin and Packer version

Packer version: 1.8.0
VirtualBox plugin version: Whatever is being included in Packer 1.8.0

Simplified Packer Buildfile

source "virtualbox-iso" "test" {
  guest_os_type        = "Windows10_64"
  iso_url              = "windows.iso"
  iso_checksum         = "md5:6E7CF41B5387293E55BF693432F6C97B"
  communicator         = "winrm"
  winrm_username       = "packer"
  winrm_password       = "packer"
  winrm_insecure       = true
  winrm_use_ssl        = true
  shutdown_command     = "shutdown /s /t 10 /f /d p:4:1 /c Packer"
  guest_additions_mode = "disable"
  headless             = false
  memory               = 4096
  cpus                 = 2
  gfx_vram_size        = 128
  gfx_controller       = "vboxsvga"
  format               = "ova"
  floppy_content = {
    "user-data" = "foo"
  }
}

build {
  sources = ["sources.virtualbox-iso.test"]

  provisioner "powershell" {
    inline = ["write-output hello"]
  }
}

Operating system and Environment details

  • Ubuntu 20.04 on WSL 2
  • VirtualBox 6.1.32

Notes

I did some investigating and while the FloppyContent config is defined in packer-plugin-sdk/multistep/commonsteps/floppy_config.go:

type FloppyConfig struct {
	FloppyFiles []string `mapstructure:"floppy_files"`
	FloppyDirectories []string `mapstructure:"floppy_dirs"`
	FloppyContent map[string]string `mapstructure:"floppy_content"`
	FloppyLabel   string            `mapstructure:"floppy_label"`
}

It doesn't appear to be used when creating the floppy:

&commonsteps.StepCreateFloppy{
Files: b.config.FloppyConfig.FloppyFiles,
Directories: b.config.FloppyConfig.FloppyDirectories,
Label: b.config.FloppyConfig.FloppyLabel,
},

Guest Additions ISO using wrong sata priority

This issue was originally opened by @loynoir as hashicorp/packer#11100. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

Because of guest additions iso images using wrong priority, virtualbox build failed with

FATAL: Could not read from the boot medium! System halted.

Reproduction Steps

packer build \
-only=virtualbox-iso \
-var 'headless=false' \
thirdparty/github.com/chef/bento/packer_templates/windows/windows-10.json

Actual

Guest additions iso has higher priority than windows iso.

Guest additions iso using sata port n.
Windows image using sata port n + 1, which has lower priority.

Expected

Guest additions iso has lower priority than windows iso.

Manual Workaround

goto Virtualbox>Devices>OpticalDevices
swap two iso images,
make sure lower number refer to windows iso image.
<C-r> to reboot or said reset.
Now it works.

Packer version

packer: 1.7.2

Simplified Packer Buildfile

Operating system and Environment details

OS: archlinux
virtualbox: 6.1.22-2

Log Fragments and crash.log files

Error unregistering floppy: VBoxManage error: VBoxManage: error: Could not find a controller named 'Floppy Controller'. Not considering this a critical failure; build will continue.

This issue was originally opened by @KptnKMan in hashicorp/packer#11935 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

This seems to be an issue that has been occuring since earlier than 2016, and continues to present itself, across platforms and use cases. There are dozens of issues logged in this project, but I want to bring particular attention to #2401 which was logged in 2015, and was closed in 2020, but is still not resolved. There are earlier examples like #1193 and later examples also.

==> virtualbox-iso: Cleaning up floppy disk...
==> virtualbox-iso: Error unregistering floppy: VBoxManage error: VBoxManage: error: Could not find a controller named 'Floppy Controller'. Not considering this a critical failure; build will continue.
==> virtualbox-iso: Deregistering and deleting VM...

I am experiencing this issue, and it crashes my build and deletes all my efforts basically every time after hours of running, unless I can literally snatch the image file away before packer gets a chance.

That this has gone on for so long unresolved, I'm not sure what to say. Can something be done about this, beyond workarounds adjusting timeouts of shutdown_timeout and post_shutdown_delay?

I have adjusted these timeouts higher and higher, and still experience this issue. Running headless doesn't help. I would appreciate if this could get beyond screaming into the void, and nothing being done about it.

Reproduction Steps

Run Packer template as normal.
Issue occurs at end of runtime.

Packer version

Packer v1.8.2
on Ubuntu 20.04
Virtualbox 6.1.34_Ubuntur150636

Simplified Packer Template

In this example am using packer recommended scripts from:
https://github.com/StefanScherer/packer-windows

{
  "builders": [
    {
      "boot_command": [
        "<leftShiftOn><f10><leftShiftOff><wait>",
        "reg add HKLM\\SYSTEM\\Setup\\LabConfig /t REG_DWORD /v BypassTPMCheck /d 1<return>",
        "reg add HKLM\\SYSTEM\\Setup\\LabConfig /t REG_DWORD /v BypassSecureBootCheck /d 1<return><wait>",
        "reg add HKLM\\System\\Setup\\LabConfig /t REG_DWORD /v BypassRAMCheck /d 1<return><wait>",
        "reg add HKLM\\System\\Setup\\LabConfig /t REG_DWORD /v BypassCPUCheck /d 1<return><wait>",
        "reg add HKLM\\System\\Setup\\LabConfig /t REG_DWORD /v BypassStorageCheck /d 1<return><wait>",
        "exit<return>",
        "<wait><return>"
      ],
      "boot_wait": "2m",
      "communicator": "winrm",
      "cpus": "{{user `cpus`}}",
      "disk_size": "{{user `disk_size`}}",
      "floppy_files": [
        "./answer_files/11_efi/Autounattend.xml",
        "./scripts/fixnetwork.ps1",
        "./scripts/disable-screensaver.ps1",
        "./scripts/disable-winrm.ps1",
        "./scripts/enable-winrm.ps1",
        "./scripts/microsoft-updates.bat",
        "./scripts/win-updates.ps1"
      ],
      "cd_files": [
        "./answer_files/11_efi/Autounattend.xml",
        "./scripts/fixnetwork.ps1",
        "./scripts/disable-screensaver.ps1",
        "./scripts/disable-winrm.ps1",
        "./scripts/enable-winrm.ps1",
        "./scripts/microsoft-updates.bat",
        "./scripts/win-updates.ps1"
      ],
      "cd_label": "unattend",
      "guest_additions_mode": "disable",
      "guest_os_type": "Windows11_64",
      "headless": "{{user `headless`}}",
      "iso_checksum": "{{user `iso_checksum`}}",
      "iso_url": "{{user `iso_url`}}",
      "memory": "{{user `memory`}}",
      "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
      "type": "virtualbox-iso",
      "vm_name": "{{user `vm_name`}}",
      "name": "windows_11_vboxiso_efi",
      "winrm_password": "vagrant",
      "winrm_timeout": "{{user `winrm_timeout`}}",
      "winrm_username": "vagrant",
      "firmware": "efi",
      "gfx_controller": "vboxsvga",
      "gfx_vram_size": "128",
      "gfx_accelerate_3d": "true"
    }
  ],
  "post-processors": [
    {
      "type": "amazon-import",
      "boot_mode": "uefi",
      "region": "{{user `region`}}",
      "profile": "{{user `profile`}}",
      "role_name": "{{user `role_name`}}",
      "s3_bucket_name": "{{user `s3_bucket_name`}}",
      "s3_key_name": "{{user `s3_key_name`}}",
      "s3_encryption": "{{user `s3_bucket_encryption`}}",
      "format": "{{user `vm_image_format`}}",
      "keep_input_artifact": false,
      "license_type": "{{user `license_type`}}",
      "ami_encrypt": "{{user `ami_encrypt`}}",
      "ami_kms_key": "{{user `ami_encrypt_kms_key`}}",
      "ami_name": "{{user `environment`}}-{{user `service-team`}}-{{user `created-by`}}-{{user `service-component`}}{{user `ami_name_suffix`}}",
      "tags": {
        "Name": "{{user `environment`}}-{{user `service-team`}}-{{user `created-by`}}-{{user `service-component`}}{{user `ami_name_suffix`}}",
        "environment": "{{user `environment`}}",
        "service-team": "{{user `service-team`}}",
        "created-by": "{{user `created-by`}}",
        "service-component": "{{user `service-component`}}",
        "tagging-version": "{{user `tagging-version`}}",
        "source-ami": "{{user `iso_url`}}",
        "build-time": "{{isotime \"20060102-1504\"}}",
        "build-id": "{{user `build_id`}}"
      }
    }
  ],
  "provisioners": [
    {
      "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
      "remote_path": "/tmp/script.bat",
      "scripts": [
        "./scripts/enable-rdp.bat"
      ],
      "type": "windows-shell"
    },
    {
      "scripts": [
        "./scripts/vm-guest-tools.ps1",
        "./scripts/debloat-windows.ps1"
      ],
      "type": "powershell"
    },
    {
      "restart_timeout": "{{user `restart_timeout`}}",
      "type": "windows-restart"
    },
    {
      "scripts": [
        "./scripts/set-powerplan.ps1",
        "./scripts/docker/disable-windows-defender.ps1"
      ],
      "type": "powershell"
    },
    {
      "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"",
      "remote_path": "/tmp/script.bat",
      "scripts": [
        "./scripts/compile-dotnet-assemblies.bat",
        "./scripts/set-winrm-automatic.bat",
        "./scripts/uac-enable.bat",
        "./scripts/dis-updates.bat",
        "./scripts/compact.bat"
      ],
      "type": "windows-shell"
    }
  ]
}

Operating system and Environment details

Ubuntu 20.04
Virtualbox 6.1.34_Ubuntur150636

Log Fragments and crash.log files

...
==> virtualbox-iso: 2022-08-11 12:26:25 Info: Sysprep command: C:\Windows\System32\Sysprep\Sysprep.exe /oobe /quit /generalize /unattend:C:\ProgramData\Amazon\EC2Launch\sysprep\unattend.xml
    virtualbox-iso:
    virtualbox-iso: C:\Users\Administrator>shutdown /s /t 10 /f /d p:4:1
==> virtualbox-iso: Automatic shutdown disabled. Please shutdown virtual machine.
    virtualbox-iso: Removing floppy drive...
==> virtualbox-iso: Preparing to export machine...
    virtualbox-iso: Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port 3551)
==> virtualbox-iso: Exporting virtual machine...
    virtualbox-iso: Executing: export win11base --output output-virtualbox-iso/win11base.ova --manifest --vsys 0 --description Windows 11 Enterprise V10.0.22000 SPB318 --version 0.1.0
==> virtualbox-iso: Cleaning up floppy disk...
==> virtualbox-iso: Error unregistering floppy: VBoxManage error: VBoxManage: error: Could not find a controller named 'Floppy Controller'. Not considering this a critical failure; build will continue.
==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Running post-processor: amazon-import
...

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...
...

{{.ArtifactId}} is not defined in parallel build

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

When using the vagrant post-processer on boxes built through parrallel builds there is no real {{.ArtifactId}} for boxes built with the virtualbox plugin but there is for boxes built with the vmware plugin.

For virtualbox builds the {{.ArtifactId}} is not present in the manifest.

For vmware builds the {{.ArtifactId}} is the vm_name.

Why is this an issue?

Vagrant post-processor defaults to using {{.BuildName}} in output, {{.BuildName}} ends up being the top level template, "virtualbox-iso.default" or "vmware-iso.default" in this case, a unique output name is required to run multiple builds through the Vagrant post-processor without overwriting the previous.

Reproduction Steps

With Simplified Packer Template

For packer build -only=roles.virtualbox-iso.1 .

artifact_id is VM in the manifest

output/packer-manifest.json

...
      "artifact_id": "VM",
...

Vagrant outputs box to "output/VM.box"

For packer build -only=roles.vmware-iso.1 .

the artifact_id is the vm_name in the manifest

output/packer-manifest.json

...
      "artifact_id": "vmware-box1",
...

Vagrant outputs box to "output/vmware-box1.box"

{{.ArtifactId} should reflect the vm_name as the vmware plugin does so this can be used to uniquely name outputted boxes.

Packer version

Packer v1.8.3
packer-plugin-virtualbox_v1.0.4_x5.0_darwin_amd64
packer-plugin-vmware_v1.0.7_x5.0_darwin_amd64

Simplified Packer Template

Attempted to simplify as much as possible.

source "virtualbox-iso" "default" {
  cpus = "${var.cpus}"
  disk_size  = "${var.disk_size}"
  memory  = "${var.memory}"
  "{{  Other Common Parameters }}"
}
source "vmware-iso" "default" {
  cpus = "${var.cpus}"
  disk_size  = "${var.disk_size}"
  memory  = "${var.memory}"
  "{{ Other Common Parameters }}"
}
build {
  name = "roles"
  source "virtualbox-iso.1" {
    vm_name: virtualbox-box1
   "{{ VirtualBox-1 Specific Parameters }}"
  }
  source "virtualbox-iso.2" {
    vm_name: virtualbox-box2
    "{{ VirtualBox-2 Specific Parameters }}"
  }
  source "vmware-iso.1" {
    vm_name: vmware-box1
    "{{ VMWare-1 Specific Parameters }}"
  }
  source "vmware-iso.2" {
    vm_name: vmware-box2
    "{{ VMWare-2 Specific Parameters }}"
  }
  post-processor "manifest" {
  }
  post-processor "vagrant" {
    output = "output/{{.ArtifactId}}.box"
  }
}

Operating system and Environment details

MacOS Monterey Version 12.5 (Intel Processor)

Log Fragments and crash.log files

N/A

Packer SSH communicator `ssh_port` argument value is ignored

Overview of the Issue

When specifying a value for the argument ssh_port, the argument value is ignored, and instead the port is chosen from the range specified by host_port_min and host_port_max is selected. I have repeated this multiple times to verify the behavior.

Reproduction Steps

packer build

Plugin and Packer version

1.8.3 and 1.0.4

Simplified Packer Buildfile

source "virtualbox-vm" "ubuntu" {
  ssh_host = "127.0.0.1"
  ssh_port = "2222"
}

Operating system and Environment details

n/a

Log Fragments and crash.log files

2022/09/08 15:19:29 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/09/08 15:19:29 [INFO] Attempting SSH connection to 127.0.0.1:3171...
2022/09/08 15:19:29 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/09/08 15:19:29 [DEBUG] reconnecting to TCP connection for SSH
2022/09/08 15:19:29 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/09/08 15:19:29 [DEBUG] handshaking with SSH
2022/09/08 15:19:29 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/09/08 15:19:29 [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:42718->127.0.0.1:3171: read: connection reset by peer

Environment variable LOGNAME or USER does not correspond to effective user id

Overview of the Issue

Running packer on a host indirectly. I'm seeing a warning that looks like it is causing a parsing error. when doing a VBoxManage --version.

This is the error:

Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id. 7.0.16r162802

Reproduction Steps

I'm only able reproduce using this indirect call to packer through another tool. Error seems to be here:

versionRe := regexp.MustCompile("^([.0-9]+)(?:_(?:RC|OSEr)[0-9]+)?")
when a string is prepended to the version.

Plugin and Packer version

Packer v1.10.2

Simplified Packer Buildfile

If the file is longer than a few dozen lines, please include the URL to the
gist of the log or use the Github detailed
format

instead of posting it directly in the issue.

Operating system and Environment details

Happens on Ubuntu and Rocky Linux.

Log Fragments and crash.log files

virtualbox-iso.vm: output will be in this color.
2024/04/29 20:44:09 packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64 plugin: 2024/04/29 20:44:09 VBoxManage path: /usr/bin/VBoxManage
2024/04/29 20:44:09 packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64 plugin: 2024/04/29 20:44:09 VBoxManage --version output: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
2024/04/29 20:44:09 packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64 plugin: 7.0.16r162802
2024/04/29 20:44:09 [INFO] (telemetry) ending virtualbox-iso.vm
7.0.16r162802
==> Wait completed after 29 milliseconds 413 microseconds
2024/04/29 20:44:09 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2024/04/29 20:44:09 machine readable: virtualbox-iso.vm,error []string{"Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.\n7.0.16r162802"}
7.0.16r162802
==> Builds finished but no artifacts were created.
2024/04/29 20:44:09 [INFO] (telemetry) Finalizing.
Build 'virtualbox-iso.vm' errored after 29 milliseconds 337 microseconds: Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
7.0.16r162802
==> Wait completed after 29 milliseconds 413 microseconds
==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
7.0.16r162802
==> Builds finished but no artifacts were created.
2024/04/29 20:44:10 waiting for all plugin processes to complete...
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /tmp/runner-3846468805/.config/packer/plugins/github.com/hashicorp/virtualbox/packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited

Chef-solo provisioning on Windows

This issue was originally opened by @Chan9390 as hashicorp/packer#5220. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Chef solo isn't installing on Windows Server 2008 R2. Other provisioning like shell and powershell are working fine, but when it comes to chef-solo provisioning, the inbuilt installation script gets stuck.

I tried the following workarounds:

  • Overriding the inbuilt command with install_command. Doesnt work
  • Have a shell provisioning with installation command. Doesnt work
  • Have a powershell provisioning with installation command. Doesnt work

The guest VM is Windows Server 2008 R2. It has dotNet 4.5 and Windows Management Framework 5.0 installed (Powershell v5 is present).

  • Packer version : Tested with 1.0.0 and 1.0.3

  • Host platform : Ubuntu 16.04

  • End output from logs:

    2017/08/04 21:10:01 [INFO] (telemetry) Starting provisioner chef-solo
    2017/08/04 21:10:01 ui: ==> virtualbox-iso: Provisioning with chef-solo
    2017/08/04 21:10:01 ui:     virtualbox-iso: Installing Chef...
    2017/08/04 21:10:01 packer: 2017/08/04 21:10:01 opening new ssh session
    2017/08/04 21:10:01 packer: 2017/08/04 21:10:01 starting remote command: powershell.exe -Command ". { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; Install-Project"
    2017/08/04 21:10:22 ui:     virtualbox-iso:
    2017/08/04 21:10:22 ui:     virtualbox-iso: ModuleType Version    Name                                ExportedCommands
    2017/08/04 21:10:22 ui:     virtualbox-iso: ---------- -------    ----                                ----------------
    2017/08/04 21:10:22 ui:     virtualbox-iso: Script     0.0        Omnitruck                           {Get-ProjectMetada...
    
  • Provisioning script:

      {
        "type": "chef-solo",
        "guest_os_type": "windows",
        "cookbook_paths": ["chef/cookbooks"],
        "run_list": [
          "recipe[metasploitable::root_certs]",
          "recipe[metasploitable::vagrant_ssh]",
          "recipe[metasploitable::disable_auto_logon]",
          "recipe[metasploitable::enable_rdp]"
        ]
      },
    

Look at the entire script here.

HTTP server is unreachable by default in recent Virtualbox versions

Overview of the Issue

Starting from Virtualbox 7.0.0, packer http server is not reachable from the guests by default.

This is due to a new security option --nat-localhostreachableN (introduced in Virtualbox 7.0.0) which is "off" by default, disabling access to host gateway (10.0.2.2) directly. This is not apparent in changelogs as this is a security change, which Oracle does not communicate transparently.

Thanks klaus-vb from #vbox:irc.oftc.net for this info!

Proposed fix

Configure virtualbox vm with --nat-localhostreachable1 on on Virtualbox versions >= 7.0.0 (<7.0.0 do not have this option).

Until then, this is the workaround:

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

Reproduction Steps

See hashicorp/packer#12118

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

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


Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

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.

VirtualBox 6.x using Hyper-v (for WSL2) backend breaks SSH/SCP comms

This issue was originally opened by @ciarancourtney as hashicorp/packer#9411. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

Not saying this is a packer issue, just a placeholder in case anyone else encounters it and is flummoxed like I was.

Getting error Error uploading guest additions: ssh: disconnect, reason 2: Packet corrupt.

Trying to SCP same file (or any file of significant size) on command line fails with same error.

Guest OS is CentOS 6.10

Tread here mentions similar issues incl segfaults and issues computing SHA256 sums.

Turning off Hyper-V resolves issue:

bcdedit /set hypervisorlaunchtype off
** reboot **

Reproduction Steps

Do a virtualbox-iso build incl guest upload on Windows 10 with the new WSL2 hyper-v features enabled.

Packer version

1.5.6 & 1.6.0 tested

Simplified Packer Buildfile

      "type": "virtualbox-iso",
      "guest_os_type": "RedHat_64",
      "guest_additions_mode": "upload",
      "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
      "virtualbox_version_file": ".vbox_version",

Operating system and Environment details

  • Windows 10 2004 (20H1)
  • VirtualBox v6.1.8 (hyper-v not mentioned in v6.1.10 changelog)
    • WSL2 installed, so vbox is using the hyper-v backend (green turtle in status bar)

Log Fragments and crash.log files

2020/06/11 17:13:27 packer.exe plugin: [INFO] Attempting SSH connection to 127.0.0.1:3041...
2020/06/11 17:13:27 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2020/06/11 17:13:27 packer.exe plugin: [DEBUG] handshaking with SSH
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] handshake complete!
2020/06/11 17:13:28 packer.exe plugin: [ERROR] could not connect to local agent socket: C:/Users/ciara/AppData/Local/Temp/ssh-nOvGQ9u9tR2s/agent.744
==> virtualbox-iso: Connected to SSH!
2020/06/11 17:13:28 packer.exe plugin: VBoxManage --version output: 6.1.8r137981
2020/06/11 17:13:28 packer.exe plugin: VirtualBox version: 6.1.8
==> virtualbox-iso: Uploading VirtualBox version info (6.1.8)
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Opening new ssh session
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Starting remote scp process:  scp -vt .
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Started SCP session, beginning transfers...
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Copying input data into temporary file so we can read the length
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] scp: Uploading .vbox_version: perms=C0644 size=5
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] SCP session complete, closing stdin pipe.
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Waiting for SSH session to complete.
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] scp stderr (length 28): Sink: C0644 5 .vbox_version
2020/06/11 17:13:28 packer.exe plugin: VBoxManage --version output: 6.1.8r137981
2020/06/11 17:13:28 packer.exe plugin: VirtualBox version: 6.1.8
==> virtualbox-iso: Uploading VirtualBox guest additions ISO...
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Opening new ssh session
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Starting remote scp process:  scp -vt .
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Started SCP session, beginning transfers...
2020/06/11 17:13:28 packer.exe plugin: [DEBUG] Copying input data into temporary file so we can read the length
2020/06/11 17:13:29 packer.exe plugin: [DEBUG] scp: Uploading VBoxGuestAdditions_6.1.8.iso: perms=C0644 size=59832320
==> virtualbox-iso: Error uploading guest additions: write tcp 127.0.0.1:19925->127.0.0.1:3041: wsasend: An existing connection was forcibly closed by the remote host.
==> virtualbox-iso: Step "StepUploadGuestAdditions" failed
==> virtualbox-iso: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?

SATA optical drives mount in the wrong order

Overview of the Issue

I use the ISO builder with cd_files and guest_additions_mode = "attach", creating three optical drives. Prior to 1.7 this worked, booting into the install DVD, but after a recent upgrade my Windows 10 installer stopped working. On closer inspection I noticed the Windows ISO refused to boot, because it was not the first optical drive.

Per the documentation, "...the [extra] CD is attached as the second CD device," which I have always understood to imply that the iso_url disk should be first, and the guest additions last. My inspection showed, however, in v1.7.2, the cd_files disk is installed on SATA port 13, the Guest Additions CD on port 14, and the iso_url disk on port 15. For reference, in v1.6.6, my last known good version, the iso_url disk is installed on SATA port 1, the Guest Additions CD on port 2, and the cd_files CD on port 3.

I was able to work around the immediate problem of not booting into the installer by stopping the VM, reordering the drives, rebooting, and manually entering my boot_commands. I have not yet tried using vboxmanage commands to reorder things, but I suspect that will be my interim solution.

Reproduction Steps

Create a template using the VirtualBox-ISO builder, setting both cd_files and guest_additions_mode = "attach". Start the build and inspect the VM's SATA drives.

Plugin and Packer version

$ packer version
Packer v1.7.2

Simplified Packer Buildfile

packer {
    required_version = "= 1.7.2"
    required_plugins {
        virtualbox = {
        version = "= 0.0.1"
        source  = "github.com/hashicorp/virtualbox"
    }
  }
}

build {
    source "source.virtualbox-iso.windows-10" {
        guest_os_type = "Windows10_64"

        iso_interface = "sata"
 
        vboxmanage = [
            ["modifyvm", "{{.Name}}", "--firmware", "EFI"]
        ]
       
        iso_url = "/Users/alice/Downloads/en_windows_10_enterprise_ltsc_2019_x64_dvd.iso"
        cd_files = ["cd/touched.file"]
        guest_additions_mode = "attach"
   }
}

Operating system and Environment details

macOS Catalina
10.15.7

$ uname -v
Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64

Log Fragments and crash.log files

2021/04/26 19:47:31 ui: ==> base.virtualbox-iso.atm-windows-10-base: Mounting ISOs...
2021/04/26 19:47:31 ui:     base.virtualbox-iso.atm-windows-10-base: Mounting boot ISO...
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 Executing VBoxManage: []string{"storageattach", "packer-windows-10-1619480840", "--storagectl", "SATA Controller", "--port", "15", "--device", "0", "--type", "dvddrive", "--medium", "/Users/alice/Downloads/en_windows_10_enterprise_ltsc_2019_x64_dvd.iso"}
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stdout:
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stderr:
2021/04/26 19:47:31 ui:     base.virtualbox-iso.atm-windows-10-base: Mounting cd_files ISO...
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 Executing VBoxManage: []string{"storageattach", "packer-windows-10-1619480840", "--storagectl", "SATA Controller", "--port", "13", "--device", "0", "--type", "dvddrive", "--medium", "/private/var/folders/sm/h0wmfgys66g6pv2_g6nbbvr40000gq/T/packer537259108.iso"}
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stdout:
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stderr:
2021/04/26 19:47:31 ui:     base.virtualbox-iso.atm-windows-10-base: Mounting guest additions ISO...
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 Executing VBoxManage: []string{"storageattach", "packer-windows-10-1619480840", "--storagectl", "SATA Controller", "--port", "14", "--device", "0", "--type", "dvddrive", "--medium", "/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso"}
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stdout:
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stderr:

Packer (virtualbox-iso) sets HTTPIP to 10.0.2.2 but serves traffic on 10.0.2.3!

This issue was originally opened by @autumnjolitz in hashicorp/packer#12298 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Overview of the Issue

The ip address provided at variable HTTPIP is incorrect.

Reproduction Steps

  1. packer build cerberus-dragonfly.pkr.hcl
  2. wait for the VM to start and get to a shell
  3. watch as it just hangs on fetch
  4. Control-C out of it inside the vm and try curl http://10.0.2.3/init.sh instead

Packer version

Packer v1.8.6

Simplified Packer Template

https://github.com/autumnjolitz/cerberus_gateway/

Operating system and Environment details

Mac OSX 11.4, x86-64
Packer version: 1.8.6 [go1.19.6 darwin amd64]

Log Fragments and crash.log files

Log file: https://gist.github.com/autumnjolitz/276a5976ea085997ba0123e0df771069

virtualbox-ovf with no EULA acceptance can exit with `VBoxManage: error: Could not find a registered machine`

This issue was originally opened by @akkornel as hashicorp/packer#10777. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

As noted in the VirtualBox OVF builder page (specifically in the discussion of import_flags), importing an OVF/OVA might require accepting a license agreement that is bundled in with the OVF/OVA. The problem I'm reporting is this: If a EULA is required, but import_flags is not set, Packer will give an obscure error message.

The error message shown is Error enabling VRDP: VBoxManage error: VBoxManage: error: Could not find a registered machine named โ€ฆ.

In other words, Packer isn't failing on OVA import (where EULA acceptance would be relayed to VirtualBox), Packer is failing on a later step.

I think the root cause is actually a bug with VBoxManage: Even though there is a license-acceptance error, the VBoxManage command is exiting with exit code zero. I think Packer is taking that exit code to mean that things are working fine. I reported this issue to Oracle, here: https://www.virtualbox.org/ticket/20261

I am reporting the issue here for two reasons:

  1. The error coming from Packer does not clearly show where the problem is.
  2. There might be something that Packer can do in the meantime, while waiting for the bug to be patched and a new VirtualBox release to be made.
  3. I couldn't find this issue reported anywhere, so by reporting it here, I hope to help anyone else who is also looking.

Reproduction Steps

  1. Download the Debian 10 VirtualBox image from linuxvmimages.com (direct link: https://sourceforge.net/projects/linuxvmimages/files/VirtualBox/D/10/Debian_10.7.0_VB.zip/download). The download comes as a .zip file, so unzip that to get the actual OVA.
  2. Copy the simplified packer buildfile. Fix up the path to the OVA file. Save as deb.pkr.hcl.
  3. Run packer build deb.pkr.hcl. You should get an error Error enabling VRDP: VBoxManage error: VBoxManage: error: Could not find a registered machine named โ€ฆ
  4. Edit the packer buildfile, uncommenting the commented-out lines.
  5. Re-run packer build deb.pkr.hcl. The build should succeed.

Packer version

1.7.0

Simplified Packer Buildfile

I have this buildfile named deb.pkr.hcl on my computer. Just FYI, as you'll see that name later in the log dump. You'll also need to fix up the source_path if you try this yourself.

source "virtualbox-ovf" "deb" {
  source_path = "/Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova"
  checksum = "md5:05cd281a26d258d141e3241072796129"
#  import_flags = [
#    "--vsys",
#    "0",
#    "--eula",
#    "accept"
#  ]
  ssh_username = "debian"
  ssh_password = "debian"
  acpi_shutdown = true
}

build {
  sources = [
    "sources.virtualbox-ovf.deb"
  ]
}

Operating system and Environment details

macOS Catalina 10.15.7, running on Intel 64-bit.

iTerm2 3.4.4, with the macOS bash shell.

Packer 1.7.0 downloaded from https://releases.hashicorp.com/packer/1.7.0/packer_1.7.0_darwin_amd64.zip

Log Fragments and crash.log files

Output from `PACKER_LOG=1 ./packer build deb.pkr.hcl`
ITS-C02C91G0MD6R:~/Downloads/packer akkornel(p)$ PACKER_LOG=1 ./packer build deb.pkr.hcl
2021/03/17 09:06:35 [INFO] Packer version: 1.7.0 [go1.15.8 darwin amd64]
2021/03/17 09:06:35 [TRACE] discovering plugins in /Users/akkornel/Downloads/packer
2021/03/17 09:06:35 [TRACE] discovering plugins in /Users/akkornel/.packer.d/plugins
2021/03/17 09:06:35 [TRACE] discovering plugins in .
2021/03/17 09:06:35 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/03/17 09:06:35 [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/akkornel/.packerconfig
2021/03/17 09:06:35 [WARN] Config file doesn't exist: /Users/akkornel/.packerconfig
2021/03/17 09:06:35 [INFO] Setting cache directory: /Users/akkornel/Downloads/packer/packer_cache
2021/03/17 09:06:35 [TRACE] Starting internal plugin packer-builder-virtualbox-ovf
2021/03/17 09:06:35 Starting plugin: /Users/akkornel/Downloads/packer/packer []string{"/Users/akkornel/Downloads/packer/packer", "plugin", "packer-builder-virtualbox-ovf"}
2021/03/17 09:06:35 Waiting for RPC address for: /Users/akkornel/Downloads/packer/packer
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: [INFO] Packer version: 1.7.0 [go1.15.8 darwin amd64]
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/akkornel/.packerconfig
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: [WARN] Config file doesn't exist: /Users/akkornel/.packerconfig
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: [INFO] Setting cache directory: /Users/akkornel/Downloads/packer/packer_cache
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: args: []string{"packer-builder-virtualbox-ovf"}
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Plugin address: unix /var/folders/yv/2nf8pvw54f1d_c6s28v8pdb40000gp/T/packer-plugin161715859
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Waiting for connection...
2021/03/17 09:06:35 Received unix RPC address for /Users/akkornel/Downloads/packer/packer: addr is /var/folders/yv/2nf8pvw54f1d_c6s28v8pdb40000gp/T/packer-plugin161715859
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Serving a plugin connection...
will forcibly halt the virtual machine, which may result in data loss.

  on deb.pkr.hcl line 1:
  (source code not available)

2021/03/17 09:06:35 Build debug mode: false
2021/03/17 09:06:35 Force build: false
2021/03/17 09:06:35 On error:
2021/03/17 09:06:35 Waiting on builds to complete...
2021/03/17 09:06:35 Starting build run: virtualbox-ovf.deb
2021/03/17 09:06:35 Running builder:
Warning: A shutdown_command was not specified. Without a shutdown command, Packer
2021/03/17 09:06:35 [INFO] (telemetry) Starting builder
will forcibly halt the virtual machine, which may result in data loss.

  on deb.pkr.hcl line 1:
  (source code not available)


virtualbox-ovf.deb: output will be in this color.

2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: VBoxManage path: /usr/local/bin/VBoxManage
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Suppressing annoying messages in VirtualBox
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"setextradata", "global", "GUI/UpdateDate", "1 d, 2022-01-01, stable"}
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stdout:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stderr:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"setextradata", "global", "GUI/RegistrationData", "triesLeft=0"}
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stdout:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stderr:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"setextradata", "global", "GUI/SuppressMessages", "confirmInputCapture,remindAboutAutoCapture,remindAboutMouseIntegrationOff,remindAboutMouseIntegrationOn,remindAboutWrongColorDepth"}
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stdout:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stderr:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"setextradata", "global", "GUI/UpdateCheckCount", "60"}
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stdout:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: stderr:
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: No floppy files specified. Floppy disk will not be made.
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: No CD files specified. CD disk will not be made.
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: VBoxManage --version output: 6.1.18r142142
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: VirtualBox version: 6.1.18
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: guest_additions_url is blank; querying driver for iso.
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Found Default Guest Additions ISO: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Guest additions URL: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-ovf.deb: Retrieving Guest additions
==> virtualbox-ovf.deb: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Acquiring lock for: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso (/Users/akkornel/Downloads/packer/packer_cache/7784a55a71d48a1e9b5c487431438fef0f19d87f.iso.lock)
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Leaving retrieve loop for Guest additions
==> virtualbox-ovf.deb: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
2021/03/17 09:06:35 packer-builder-virtualbox-ovf plugin: Acquiring lock for: /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova?checksum=md5%3A05cd281a26d258d141e3241072796129 (/Users/akkornel/Downloads/packer/packer_cache/fe67faf1710b432aefa6516f5e02263d488421dc.ova.lock)
==> virtualbox-ovf.deb: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso => /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-ovf.deb: Retrieving OVF/OVA
==> virtualbox-ovf.deb: Trying /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova
==> virtualbox-ovf.deb: Trying /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova?checksum=md5%3A05cd281a26d258d141e3241072796129
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Leaving retrieve loop for OVF/OVA
==> virtualbox-ovf.deb: /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova?checksum=md5%3A05cd281a26d258d141e3241072796129 => /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"import", "/Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova", "--vsys", "0", "--vmname", "packer-deb-1615997195"}
==> virtualbox-ovf.deb: Importing VM: /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: stdout: Disks:
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:   vmdisk1	549755813888	-1	http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized	Debian_10.7.0_VB_LinuxVMImages.COM-disk001.vmdk	-1	-1
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Virtual system 0:
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  0: Suggested OS type: "Debian_64"
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --ostype <type>"; use "list ostypes" to list all possible values)
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  1: VM name specified with --vmname: "packer-deb-1615997195"
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  2: Suggested VM group "/"
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --group <group>")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  3: Suggested VM settings file name "/Users/akkornel/VirtualBox VMs/Debian_10.7.0_VB_LinuxVMImages.COM/Debian_10.7.0_VB_LinuxVMImages.COM.vbox"
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --settingsfile <filename>")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  4: Suggested VM base folder "/Users/akkornel/VirtualBox VMs"
==> virtualbox-ovf.deb: Mounting ISOs...
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --basefolder <path>")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  5: Product (ignored): Debian 10.7.0
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  6: Vendor (ignored): Debian Community
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  7: Version (ignored): 10.7.0
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  8: ProductUrl (ignored): https://www.linuxvmimages.com/debian-10
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:  9: VendorUrl (ignored): https://debian.org
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 10: Description "Debian 10.7.0 VirtualBox Image
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: User Name: debian
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Password: debian"
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --description <desc>")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 11: End-user license agreement
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (display with "--vsys 0 --eula show";
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     accept with "--vsys 0 --eula accept")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 12: Number of CPUs: 2
    virtualbox-ovf.deb: No ISOs to mount; continuing...
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --cpus <n>")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 13: Guest memory: 2048 MB
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change with "--vsys 0 --memory <MB>")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 14: Sound card (appliance expects "", can change on import)
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (disable with "--vsys 0 --unit 14 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 15: USB controller
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (disable with "--vsys 0 --unit 15 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 16: Network adapter: orig Bridged, config 3, extra slot=0;type=Bridged
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 17: CD-ROM
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (disable with "--vsys 0 --unit 17 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 18: IDE controller, type PIIX4
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (disable with "--vsys 0 --unit 18 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 19: IDE controller, type PIIX4
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (disable with "--vsys 0 --unit 19 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 20: SATA controller, type AHCI
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (disable with "--vsys 0 --unit 20 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: 21: Hard disk image: source image=Debian_10.7.0_VB_LinuxVMImages.COM-disk001.vmdk, target path=Debian_10.7.0_VB_LinuxVMImages.COM-disk001.vmdk, controller=20;channel=0
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     (change target path with "--vsys 0 --unit 21 --disk path";
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin:     disable with "--vsys 0 --unit 21 --ignore")
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Interpreting /Users/akkornel/Downloads/Debian_10.7.0_VB/Debian_10.7.0_VB_LinuxVMImages.COM.ova...
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: OK.
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: VBoxManage: error: Cannot import until the license agreement listed above is accepted.
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Not attaching guest additions since we're uploading.
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Looking for available port between 5900 and 6000 on 127.0.0.1
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Found available port: 5996 on IP: 127.0.0.1
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"modifyvm", "packer-deb-1615997195", "--vrdeaddress", "127.0.0.1", "--vrdeauthtype", "null", "--vrde", "on", "--vrdeport", "5996"}
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: stdout:
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: stderr: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp
==> virtualbox-ovf.deb: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
==> virtualbox-ovf.deb: VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5996: use of closed network connection
==> virtualbox-ovf.deb: Error enabling VRDP: VBoxManage error: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: Executing VBoxManage: []string{"unregistervm", "packer-deb-1615997195", "--delete"}
==> virtualbox-ovf.deb: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
==> virtualbox-ovf.deb: VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp
==> virtualbox-ovf.deb: Deregistering and deleting imported VM...
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: stdout:
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: stderr: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
2021/03/17 09:06:38 packer-builder-virtualbox-ovf plugin: VBoxManage: error: Context: "FindMachine(Bstr(VMName).raw(), machine.asOutParam())" at line 150 of file VBoxManageMisc.cpp
==> virtualbox-ovf.deb: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
==> virtualbox-ovf.deb: VBoxManage: error: Context: "FindMachine(Bstr(VMName).raw(), machine.asOutParam())" at line 150 of file VBoxManageMisc.cpp
==> virtualbox-ovf.deb: Error deleting VM: VBoxManage error: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'
==> virtualbox-ovf.deb: VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
2021/03/17 09:06:38 [INFO] (telemetry) ending
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp
==> virtualbox-ovf.deb: VBoxManage: error: Context: "FindMachine(Bstr(VMName).raw(), machine.asOutParam())" at line 150 of file VBoxManageMisc.cpp
==> Wait completed after 2 seconds 860 milliseconds
2021/03/17 09:06:38 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2021/03/17 09:06:38 machine readable: virtualbox-ovf.deb,error []string{"Error enabling VRDP: VBoxManage error: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'\nVBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports\nVBoxManage: error: Context: \"FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())\" at line 547 of file VBoxManageModifyVM.cpp"}
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp
==> Builds finished but no artifacts were created.
==> virtualbox-ovf.deb: Deleting output directory...
2021/03/17 09:06:38 [INFO] (telemetry) Finalizing.
Build 'virtualbox-ovf.deb' errored after 2 seconds 860 milliseconds: Error enabling VRDP: VBoxManage error: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp

==> Wait completed after 2 seconds 860 milliseconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-ovf.deb: Error enabling VRDP: VBoxManage error: VBoxManage: error: Could not find a registered machine named 'packer-deb-1615997195'
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 547 of file VBoxManageModifyVM.cpp

==> Builds finished but no artifacts were created.
2021/03/17 09:06:39 waiting for all plugin processes to complete...
2021/03/17 09:06:39 /Users/akkornel/Downloads/packer/packer: plugin process exited

Postscript

While writing up this issue, I also found an issue with the documentation on the the VirtualBox OVF builder page. Specifically, the --eula-accept option no longer exists. Instead, EULA acceptance is indicated with --vsys 0 --eula accept, which needs to be coded as four command-line options (instead of one string, see the simplified Packer build file above). I think it would be good to update the documentation, but I'm not sure how best to go about it (--vsys 0 --eula accept is much more complicated than --eula-accept), and I wasn't sure if this should be reported in a separate bug report.

As always, let me know if you have any questions, or if I got something horribly wrong!

Packer Option "-Force" does not overwrite old VM

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

Using the 'packer build -force' option does not over write the existing VM, packer will fail with error the VM already exists. If I have a failed build I should be able to rerun packer and it should delete any VM with the name it is trying to create.

Reproduction Steps

Manually running 'vboxmanage unregistervm [VM NAME] --delete' and rerunning packer resolves the issue

Plugin and Packer version

Packer 1.9.5
vagrant plugin v1.1.1
virtualbox 7.0..12_159484

Operating system and Environment details

Rocky 8, x86_64

Log Fragments and crash.log files

Build 'virtualbox-iso.vbox-rocky-tpl' errored after 59 seconds 195 milliseconds: Error creating VM: VBoxManage error: VBoxManage: error: Machine settings file '/home/user/virtual_machines/rocky-tpl/rocky-tpl.vbox' already exists
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "CreateMachine(bstrSettingsFile.raw(), bstrName.raw(), ComSafeArrayAsInParam(groups), bstrOsTypeId.raw(), createFlags.raw(), bstrCipher.raw(), bstrPasswordId.raw(), Bstr(strPassword).raw(), machine.asOutParam())" at line 406 of file VBoxManageMisc.cpp

HCL examples in virtualbox-ovf docs need updating

This issue was originally opened by @timblaktu as hashicorp/packer#10991. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Specifically, I see here, in the example about adding a description through export options the HCL example uses the old style variable reference:

"{{user `vm_description`}}"

which created an error for me initially when I copied and pasted it into my HCL project. This reference should look like this:

"${var.vm_description}"

There may be other issues with this documentation page, I just wanted to call out the one I tripped up on yesterday.

Unattend.xml not used for WS2009 with Packer & VirtualBox

This issue was originally opened by @jvuibert in hashicorp/packer#11879 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

Packer launchs the virtual machine (WS2009 Std) creation, mounts the floppy disk.
But the Windows Server 2019 Std installation stays on waiting user actions (language selection and so on) because the unattend.xml file is not used.

Reproduction Steps

  1. Create an autounattend.xml file from the WS20019 EVAL ISO file, using the Windows SIM tool
  2. Use packer + virtualbox to generate OVA file from ISO + answer file
  3. Validate packer file, then build the all

Note by opening the VFD file created by Parker, I see the content of the unattend.xml

Packer version

1.8.0

Simplified Packer Template

Packer template
https://github.com/jvuibert/packer-ws2019/blob/main/mywindows2019.pkr.hcl
Answer file
https://github.com/jvuibert/packer-ws2019/blob/main/scripts/Autounattend.xml

Operating system and Environment details

Host : Windows 10 (for Packer and Windows SIMP tool to generate the unattend.xml)
VirtualBox : 6.1.34 r150636
ISO Windows Server 2019 : 17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso

BUG: base_mac added to bundled Vagrantfiles is causing reuse of MAC addresses.

Overview of the Issue

When export VirtualBox Vagrant images/boxes the snippet:

# The contents below were provided by the Packer Vagrant post-processor

Vagrant.configure("2") do |config|
  config.vm.base_mac = "0800273XXXXX"
end

Is included. When creating multiple boxes using the same base image, you end up with multiple guests getting the same MAC address, which causes obvious problems.

Setting config.vm.ignore_box_vagrantfile = true in the local Vagrantfile acts as a workaround.

Reproduction Steps

curl -LSso Vagrantfile https://raw.githubusercontent.com/lavabit/pahoehoe/4a02650059db4647af7a67f741b4c99c92de30ae/Vagrantfile
export VAGRANT_HOME="$(pwd)/vagrant.d/"
vagrant up --provider=virtualbox

grep base_mac vagrant.d/boxes/generic-VAGRANTSLASH-debian10/*/virtualbox/Vagrantfile
vboxmanage list vms | awk -F' ' '{print $1}' | tr -d '"' | while read NAME ; do vboxmanage showvminfo $NAME --details ; done | grep -i "NIC 1" | grep MAC | sed 's/, Attachment.*//g'

This will bring up two boxes based on the generic/debian10 image and one box based on generic/centos8. The output from vboxmanage/grep should show that both Debian 10 boxes were assigned the same MAC for NIC 1.

# grep base_mac vagrant.d/boxes/generic-VAGRANTSLASH-debian10/*/virtualbox/Vagrantfile
  config.vm.base_mac = "08002757C9C6"
# vboxmanage list vms | awk -F' ' '{print $1}' | tr -d '"' | while read NAME ; do vboxmanage showvminfo $NAME --details ; done | grep -i "NIC 1" | grep MAC | sed 's/, Attachment.*//g'
NIC 1:           MAC: 08002757C9C6
NIC 1:           MAC: 08002757C9C6
NIC 1:           MAC: 08002710DD87

Plugin and Packer version

Packer 1.8.0

Simplified Packer Buildfile

git clone https://github.com/lavabit/robox && cd robox
./robox.sh box generic-debian10-virtualbox

Operating system and Environment details

Vagrant 2.2.19
VirtualBox 5.2

cd_content not working for virtualbox_iso builder

Overview of the Issue

I am using packer to build several Windows Server machines. For these I need to pass autounattend.xml. As I'm using EFI firmware using floppy is not working. Hence, I'm attaching a second ISO using cd_files and cd_content. But cd_content seems to be ignored.

The complete same setup is working for Packer Plugin Qemu. Please see the gist referenced below.

It might the the same as #40 - but for me a ISO is generated and attached. Only the file for cd_content is missing.

Reproduction Steps

  • Create a new packer buildfile.
  • Create a new example file and include a variable.
  • Include cd_files and cd_content.
  • For cd_content use templatefile to replace the variable.
  • Run the build.

cd_files will be copied to the new ISO, cd_content is not.

Plugin and Packer version

  • Packer: v1.7.8
  • packer-plugin-virtualbox: v1.0.0

Simplified Packer Buildfile

gist containing the original buildfile:

https://gist.github.com/jhorchler/9054cea17c22b60ec07584b72623f243

Operating system and Environment details

  • Arch Linux (Linux spufi 5.14.16-arch1-1 SMP PREEMPT Tue, 02 Nov 2021 22:22:59 +0000 x86_64 GNU/Linux)

Log Fragments and crash.log files

https://gist.github.com/jhorchler/9054cea17c22b60ec07584b72623f243

Packer creates multi-core VMs without enabling IO-APIC

Overview of the Issue

When defining a virtualbox-iso runner with "cpus": 2, a VM configuration will be created where the machine has multiple cores but IO-APIC is disabled.
This is indicated as invalid when opening the VM settings in VirtualBox and will automatically be fixed once the settings are saved via the UI and the machine rebooted (but not on the first boot).

This can be fixed manually by running modifyvm --ioapic on on that VM, but this should really be done internally by packer if more than one CPU core is enabled.

For 64-bit machines this does not appear to be an issue, since IO-APIC is mandated on 64-bit and probably handled by the template that is chosen through ostype.

Reproduction Steps

  1. Start a packer run using PACKER_LOG=1 packer build -debug template.json (where template.json is the attached template JSON)
  2. Inspect the Settings UI for the created VirtualBox machine, where an icon will show up in the bottom (with more information showing when hovering over it)

Plugin and Packer version

  • Packer v1.7.4

Simplified Packer Buildfile

Template JSON
{
  "builders": [
    {
      "type": "virtualbox-iso",
      "name": "debian10",
      "vm_name": "packer-debian10",
      "output_directory": "output/debian10",
      "boot_wait": "10s",
      "boot_keygroup_interval": "1s",
      "disk_size": 20480,
      "cpus": 2,
      "memory": 2048,
      "guest_os_type": "Debian",
      "headless": true,
      "vrdp_bind_address": "127.0.0.1",
      "vrdp_port_min": 11000,
      "vrdp_port_max": 12000,
      "iso_url": "https://cdimage.debian.org/cdimage/archive/10.10.0/i386/iso-cd/debian-10.10.0-i386-netinst.iso",
      "iso_checksum": "sha256:cf824084643fb82f74d1fbec804baaf74539dadd279af2098da94254f758e5b7",
      "ssh_username": "root",
      "ssh_password": "vagrant",
      "ssh_port": 22,
      "ssh_timeout": "3600s",
      "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now"
    }
  ]
}

Operating system and Environment details

OS: Arch Linux
Host architecture: amd64
Guest architecture: i386/i686

Log Fragments and crash.log files

Debug output of stepCreateVM
2021/08/21 15:37:23 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"createvm", "--name", "packer-debian10", "--ostype", "Debian", "--register"}
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: stdout: Virtual machine 'packer-debian10' is created and registered.
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: UUID: 0099d7bf-9aef-4329-b9ca-6eedcb205f38
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: Settings file: '/home/tim/.vbox/packer-debian10/packer-debian10.vbox'
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--boot1", "disk", "--boot2", "dvd", "--boot3", "none", "--boot4", "none"}
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--cpus", "2"}
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:27 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--memory", "2048"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--usb", "off"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--audio", "none", "--audiocontroller", "ac97"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--chipset", "piix3"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--firmware", "bios"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--nictype1", "82540EM", "--nictype2", "82540EM", "--nictype3", "82540EM", "--nictype4", "82540EM", "--nictype5", "82540EM", "--nictype6", "82540EM", "--nictype7", "82540EM", "--nictype8", "82540EM"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--graphicscontroller", "vboxvga", "--vram", "4"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--rtcuseutc", "off"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: Executing VBoxManage: []string{"modifyvm", "packer-debian10", "--accelerate3d", "off"}
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stdout:
2021/08/21 15:37:28 packer-builder-virtualbox-iso plugin: stderr:

`packer` hangs for a minute or two when it receives interrupt signal, `code VBOX_E_INVALID_OBJECT_STATE` in debug logs

Overview of the Issue

when I hit Ctrl + C when packer build ... is running, packer hangs for a minute or two during which my terminal does not respond to any keyboard input, before finally cleaning up the VM and exiting.

I'm not entirely sure if it's a Packer issue or a VBoxManage issue, but I figured I would get the log file out there so someone who knows the interface between Packer and VBoxManage better than I do could make that determination.

Reproduction Steps

  1. Download that build file into config.pkr.hcl.
  2. Run packer build config.pkr.hcl
  3. Wait a minute or two for the boot prompt to come up, and then in your terminal where you ran packer build hit Ctrl + C.
  4. You will see packer try to clean up the VM, which gets shut down nearly immediatly.
  5. Try to type anything in the terminal (random letters, Ctrl + C, Ctrl + \) and nothing will happen.
  6. Wait a few minutes, and packer will try to delete the machine again and will succeed.

Plugin and Packer version

Packer v1.8.4
virtualbox-iso v1.0.4

Simplified Packer Buildfile

packer {
  required_plugins {
    virtualbox = {
      version = "1.0.4"
      source = "github.com/hashicorp/virtualbox"
    }
  }
}

source "virtualbox-iso" "fedora" {
  iso_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/37/Server/x86_64/iso/Fedora-Server-netinst-x86_64-37-1.7.iso"
  iso_checksum = "sha256:149d4bae999022b07bd40f8272f6208bc28884dad5110c63e915d37458e6abc0"
  ssh_username = "packer"
  shutdown_command = "shutdown now"
  guest_os_type = "Fedora_64"
  memory = "1024"
}

build {
  name    = "fedora37-workstation"
  sources = [
    "source.virtualbox-iso.fedora"
  ]
}

Operating system and Environment details

Host OS is Fedora 37 with VirtualBox 7.0.4-1.fc37.x86_64 installed through RPMFusion.

Log Fragments and crash.log files

2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 Received interrupt signal (count: 1). Ignoring.
2022/11/28 01:59:12 Cancelling builder after context cancellation context canceled
Cancelling build after receiving interrupt
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 [WARN] Interrupt detected, quitting waiting for SSH.
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 Executing VBoxManage: []string{"controlvm", "packer-fedora-1669618637", "poweroff"}
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 stdout:
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 failed to unlock port lockfile: close tcp 127.0.0.1:2817: use of closed network connection
==> fedora37-workstation.virtualbox-iso.fedora: Cleaning up floppy disk...
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 failed to unlock port lockfile: close tcp 127.0.0.1:5984: use of closed network connection
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 Executing VBoxManage: []string{"storageattach", "packer-fedora-1669618637", "--storagectl", "IDE Controller", "--port", "0", "--device", "1", "--type", "dvddrive", "--medium", "none"}
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 stdout:
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 stderr:
==> fedora37-workstation.virtualbox-iso.fedora: Deregistering and deleting VM...
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 Executing VBoxManage: []string{"unregistervm", "packer-fedora-1669618637", "--delete"}
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 stdout:
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 stderr: VBoxManage: error: Cannot unregister the machine 'packer-fedora-1669618637' while it is locked
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: VBoxManage: error: Context: "Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(aMedia))" at line 226 of file VBoxManageMisc.cpp
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:12 Retryable error: VBoxManage error: VBoxManage: error: Cannot unregister the machine 'packer-fedora-1669618637' while it is locked
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
2022/11/28 01:59:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: VBoxManage: error: Context: "Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(aMedia))" at line 226 of file VBoxManageMisc.cpp
2022/11/28 01:59:14 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 01:59:14 [DEBUG] SSH wait cancelled. Exiting loop.
2022/11/28 02:00:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 02:00:12 Executing VBoxManage: []string{"unregistervm", "packer-fedora-1669618637", "--delete"}
2022/11/28 02:00:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 02:00:12 stdout:
2022/11/28 02:00:12 packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 plugin: 2022/11/28 02:00:12 stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
==> fedora37-workstation.virtualbox-iso.fedora: Deleting output directory...
2022/11/28 02:00:12 [INFO] (telemetry) ending virtualbox-iso.fedora
==> Wait completed after 2 minutes 55 seconds
Build 'fedora37-workstation.virtualbox-iso.fedora' errored after 2 minutes 55 seconds: Build was cancelled.
2022/11/28 02:00:12 [INFO] (telemetry) Finalizing.

==> Wait completed after 2 minutes 55 seconds
Cleanly cancelled builds after being interrupted.
2022/11/28 02:00:13 waiting for all plugin processes to complete...
2022/11/28 02:00:13 /home/wheeler/.config/packer/plugins/github.com/hashicorp/virtualbox/packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64: plugin process exited

Virtualbox-iso: NVMe not exporting properly

This issue was originally opened by @breisig as hashicorp/packer#8317. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

I am running the latest packer 1.4.5 which now supports running NVMe support in the latest Virtualbox [I am running the latest 6.0.14]. To allow virtualbox to boot an NVMe device, you have force it in EFI mode and set the ISO interface to sata to allow ISO booting in EFI mode using the following config options.

      "hard_drive_interface": "pcie",
      "iso_interface": "sata",
      "vboxmanage": [
        [ "modifyvm", "{{.Name}}", "--firmware", "efi" ]
      ]

So it looks like packer sets the NVMe device and my CentOS 8 source can install onto it but it seems when packer is shutting down the virtualbox image and and it tries to export, the following error message occurs.

==> virtualbox-iso: Preparing to export machine...
    virtualbox-iso: Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port 4429)
==> virtualbox-iso: Exporting virtual machine...
    virtualbox-iso: Executing: export centos-8-baseinstall --output source_images\centos-8-source\centos-8-baseinstall.ova
==> virtualbox-iso: Error exporting virtual machine: VBoxManage error: VBoxManage.exe: error: Cannot handle medium attachment: storageBus is 7, channel is 0, device is 0
==> virtualbox-iso: VBoxManage.exe: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component MachineWrap, interface IMachine, callee IUnknown
==> virtualbox-iso: VBoxManage.exe: error: Context: "ExportTo(pAppliance, Bstr(pszAbsFilePath).raw(), pVSD.asOutParam())" at line 1343 of file VBoxManageAppliance.cpp
==> virtualbox-iso: Provisioning step had errors: Running the cleanup provisioner, if present...
==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error exporting virtual machine: VBoxManage error: VBoxManage.exe: error: Cannot handle medium attachment: storageBus is 7, channel is 0, device is 0
VBoxManage.exe: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component MachineWrap, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "ExportTo(pAppliance, Bstr(pszAbsFilePath).raw(), pVSD.asOutParam())" at line 1343 of file VBoxManageAppliance.cpp

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: Error exporting virtual machine: VBoxManage error: VBoxManage.exe: error: Cannot handle medium attachment: storageBus is 7, channel is 0, device is 0
VBoxManage.exe: error: Details: code VBOX_E_NOT_SUPPORTED (0x80bb0009), component MachineWrap, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "ExportTo(pAppliance, Bstr(pszAbsFilePath).raw(), pVSD.asOutParam())" at line 1343 of file VBoxManageAppliance.cpp

==> Builds finished but no artifacts were created.

This issue doesn't happen when using setting it from pcie -> back to sata mode nd putting it in bios mode.

Operating system and Environment details

  • Windows 10 Pro
  • Virtualbox 6.0.14
  • Packer 1.4.5
  • [Using the latest CentOS 8 iso]

Support URLs to compressed images

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Many distributions host their ova/ovf images compressed, e.g. az 7z files, even though this typically does not save much space/bandwidth. Unfortunately this forces the user to manually download and unpack the archive and then point packer at the local file.
This workflow could be streamlined if the packer plugin itself was capable of decompressing these archives before importing them to VIrtualbox.

Potential configuration

  1. Automatically detect archive type based on extension.
  2. Specify the name of the file within archive (if applies) using archive_content_path
  3. (optional field) Allow to override the detection using archive_type
  4. (optional field) Allow to specify secondary checksum for the unpacked image using archive_content_checksum

Host OS DE become unresponsive

Overview of the Issue

When building a RHEL8 VM using virtualbox-iso the host OS hangs. I am running Fedora35 with KDE, this issue appears to be reproducible a majority of the time (9 times out of 10). To be more specific when the VM boots after having installed the OS the VM window stops updating, and all other windows in the DE fail to respond to mouse clicks or keyboard input.
I have attempted tweaking the following:

  • Disable selinux (just in case)
  • set headless=true
  • Add more vram (the default is pretty low)

Reproduction Steps

simply run the packer script below, running packer 1.8.0, using the newest virtualbox plug, and virtualbox 6.1.32

Plugin and Packer version

Packer v1.8.0

Simplified Packer Buildfile

packer {
  required_plugins {
    virtualbox = {
      version = ">= 1.0.2"
      source = "github.com/hashicorp/virtualbox"
    }
  }
}

source "virtualbox-iso" "rhel-85" {
  guest_os_type = "RedHat_64"
  iso_url = "./isos/rhel/rhel-8.5-x86_64-dvd.iso"
  iso_checksum = "md5:9c70f1acea48377b01da8066764805f9"
  cpus = 4
  memory = 4096
  http_directory = "./http/"
  ssh_username = "root"
  ssh_password = "Password1!"
  boot_command = [
    "<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/kickstart.cfg<enter><wait>"
  ]
  shutdown_command = "sudo -S shutdown -P now"
  guest_additions_path = "/tmp/"
  guest_additions_url = "./isos/vbox_guest_additions/VBoxGuestAdditions_6.1.32.iso"
  keep_registered = true
   vboxmanage = [
      [ "modifyvm", "{{.Name}}", "--groups", "/Packer Builds" ],
 ]
}

build {
  sources = ["sources.virtualbox-iso.rhel-85"]
  provisioner "shell" {
    inline = [
      "curl http://download.virtualbox.org/virtualbox/4.3.8/VBoxGuestAdditions_4.3.8.iso --output VBoxGuestAdditions_4.3.8.iso",
      "mkdir /media/VBoxGuestAdditions",
      "mount -o loop,ro VBoxGuestAdditions_4.3.8.iso /media/VBoxGuestAdditions",
      "sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run",
      "rm VBoxGuestAdditions_4.3.8.iso",
      "umount /media/VBoxGuestAdditions",
      "rmdir /media/VBoxGuestAdditions"
    ]
  }
}

Operating system and Environment details

OS: Fedora 35
Arch: x86
DE: KDE (Possibly relevant?)
Virtualbox Version: 6.1.32

Log Fragments and crash.log files

Build Log
line 237- is when I began experiencing the issue describe above

Enhancement: treat session lock error from VBoxManage as a signal that the VM is already running

This issue was originally opened by @mcandre as hashicorp/packer#9334. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Feature Description

Please treat session lock error from VBoxManage as a signal that the VM is already running. That could help packer integrate better with the hypervisor and assess VM state more accurately.

Exported VM is missing primary disk and SATA Controller

This issue was originally opened by @jchodakowski as hashicorp/packer#4637. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Using virtualbox-iso builder, I am building a two disk VM with boot and main system on /dev/sda1 and /dev/sda2 and then /dev/sdb1 as a large LVM volume with various logical volumes mounted at various places on the file system. The disk is added using vboxmanage commands, and the build works as expected. In VirtualBox, you can inspect the VM and it has all the parts as described in the json template. Once the export happens however, the SATA controller is missing, as is the first of the two disks (sda). The second disk (sdb) is exported with the machine which, once re-imported has only an IDE disk controller, one disk, and won't boot (missing the system).

Enhancement: floppy_command section similar to boot_command

This issue was originally opened by @mcandre as hashicorp/packer#8057. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Some classic operating systems such as OS/2 Warp require floppy disks to be inserted prior to loading ISO's. And so it would be helpful for Packer to provide a floppy_command section, similar to boot_command, where users can insert and remove virtual floppy diskettes with custom delays between data loads. The user configuration would look like:

floppy_command: [
    "<insert image=floppy-1.img drive=a>",
    "<wait30s>",
    "<enter>",
    "<wait5s>",
    "<remove drive=a>",
    "<wait5s>",
    "<insert image=floppy-2.img drive=a>"
    "<enter>",
    "<wait1m>",
    "<remove drive=a>",
    "<wait5s>"
],
iso_url: "winworldpc.com/os2/...",
boot_command: [
    "..."
]

As a workaround, I found a minor abuse of the guestproperty wait subcommand for the VirtualBox hypervisor, e.g. guestproperty wait <uuid> goodnight-moon --timeout <milliseconds>, followed by controlvm 'os/2' keyboardputscancode... for the Enter scancodes. Followed by controlvm <uuid> savestate to free the VM lock for the rest of the Packer build.

This happens to not depend on VirtualBox guest drivers, and guestproperty wait even exits with a zero code for now. But this could easily break in the future, and digging around with hypervisor details kind of defeats the purpose of using Packer in the first place.

Enable virtualbox-* builders to preserve .vdi format when chaining templates so disks can be resized in later stages

This issue was originally opened by @timblaktu as hashicorp/packer#10982. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


On our CI system, we've used a layered, template-chaining approach to building VMs, wherein we:

  • build base_images from iso with virtualbox-iso
    • currently these are being exported as ovf
  • build more "layers" of base images from the above .ovf using virtualbox-ovf
  • build final customized user images from any of the above .ovf using virtualbox-ovf
    • customization includes expanding the virtual disk included in the .ovf

Following this approach it does not initially appear possible to resize the virtual disk in the final virtualbox-ovf build stage because:

I see that the virtualbox-iso stepCreateDisk function hard-codes the virtual disk format to VDI. This is good because I think I can now assume that the only reason I'm getting a .vmdk is that I'm exporting to .ovf.

Without exporting from virtualbox-iso/importing into virtualbox-ovf, how can I "chain" packer virtualbox builds, while preserving the vdi file format?

I have gathered minor pieces of this puzzle, such as:

  1. I know I can skip_export but I don't see how I can import the machine with converting to ovf.
  2. I know I can vboxmanage and vboxmanage-post any commands I want, but finding the right sequence eludes me. I could clone the .vmdk as a .vdi in any build stage, but I don't understand what builder can accept a .vdi as input.

This just feels like a lot of work to figure out how to do something quite simple. FWIW I implemented this same idea effortlessly using vsphere-iso/vsphere-clone builders - all I had to do was specify the disk size in the downstream vsphere-clone builder.

Anyone have any ideas or suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.