hashicorp / packer-plugin-virtualbox

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

Missing support for floppy_content #63

Open braheezy opened 2 years ago

braheezy commented 2 years ago

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

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:

https://github.com/hashicorp/packer-plugin-virtualbox/blob/c0a89d22d6ffef3f80d7c1cead558609845ccc5e/builder/virtualbox/iso/builder.go#L399-L403