0

I have an S3 bucket of existing VMware virtual machine images (OVA format), and I want to make them compatible with Vagrant. However, I am a bit confused about the structure of how Vagrant images are packaged.

It seems like there are two separate metadata.json files that one needs to consider:

  1. The metadata.json that goes inside of the .box file
  2. The metadata.json that lists all of the .box files with the different providers

The Vagrant documentation talking about the Box File Format lists a quick example for the metadata.json. What does make sense is that you need a metadata.json file to serve as an index for all of the version / provider combinations like the following:

{
  "name": "hashicorp/bionic64",
  "description": "This box contains Ubuntu 18.04 LTS 64-bit.",
  "versions": [
    {
      "version": "0.1.0",
      "providers": [
        {
          "name": "virtualbox",
          "url": "http://example.com/bionic64_010_virtualbox.box",
          "checksum_type": "sha1",
          "checksum": "foo"
        }
      ]
    }
  ]
}

This would be #2 above. But what about the .box file itself? What does one need to do to take an OVA (or any disk image really) and make it into a .box file for use in Vagrant?

1 Answer 1

0

I actually figured this out by running a test packer build to see exactly what it did to convert a VMware build into a Vagrant box. Turns out, the .box files are just compressed tarballs. Running tar -xzf <some-box>.box will show the contents.

$ tar -xvzf mybox.box

x Vagrantfile
x box.ovf
x metadata.json
x mybox.vmdk

The box.ovf and mybox.vmdk files are taken from the original OVA image. The metadata.json file simply had the JSON {"provider":"virtualbox"} as its contents. I'm not sure the Vagrantfile file is needed, but it had the following contents:

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

Vagrant.configure("2") do |config|
  config.vm.base_mac = "000000000000" # Original MAC address removed
end


# The contents below (if any) are custom contents provided by the
# Packer template during image build.

So to do what's mentioned in this ticket, all that's needed is to compress these files into a .box file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .