4

I have a custom box named package.box. I get this error when trying to vagrant up, vagrant box add. I created a metadata.json file with different configurations but with no luck. I don't understand this message. I use virtualbox for provisioning.

I don't understand the documentation on their website regarding metadata.json file.

The "metadata.json" file for the box 'package.box' was not found.
Boxes require this file in order for Vagrant to determine the
provider it was made for. If you made the box, please add a
"metadata.json" file to it. If someone else made the box, please
notify the box creator that the box is corrupt. Documentation for
box file format can be found at the URL below:
https://www.vagrantup.com/docs/boxes/format.html

The package.box lives in am empty directory. Next to it I put this metadata.json file:

{
    "description": "long box description",
    "short_description": "short box description",
    "name": "company/developer-environment",
    "versions": [{
        "version": "1",
        "status": "active",
        "description_html": "<p>Dev Environment</p>",
        "description_markdown": "Dev Environment",
        "providers": [{
            "name": "virtualbox",
            "url": "./package.box"
        }]
    }]
}

I use a ubuntu 16.04 system, vagrant 1.8.5, virtualbox 5.0.26.

Filburt
  • 17,626
  • 12
  • 64
  • 115
etudor
  • 1,183
  • 1
  • 11
  • 19

2 Answers2

4

the package.box file is a zip file of your VM, the metadata.json file must not be next the the package.box file but inside it.

so store the metadata file next to the VM file before you package the box, something like

.
|-- box-disk1.vmdk
|-- box.ovf
|-- metadata.json

so when you run vagrant package it will include the metadata file as part of the box file.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • Thank you. It worked fine after I repackaged the box. I don't know why but it worked. The metadata file existed in the first place there. – etudor Jul 27 '16 at 13:37
  • Since he gave you the answer. Don't hesitate mark his response as the answer. – Adam Apr 23 '18 at 20:58
0

Disclaimer: This is not an answer, but a follow up question.

This looks exactly like the problem that I'm having. As I cannot fetch the metadata.json from Artifactory.

How can I pack my metadata.json into my .box file?

I have my box created in two steps.

First: Base Image which produces a *.vmdk and *.ovf file

Done with

"post-processors": [
    {
      "type": "artifice",
      "files": [
        "builds/{{.BuildName}}-{{.Provider}}-centos7.vmdk",
        "builds/{{.BuildName}}-{{.Provider}}-centos7.ovf"
      ]
    },
    {
      "type": "vagrant",
      "keep_input_artifact": true,
      "provider_override": "virtualbox"
    }
  ]

Second: I install my web-application into the image, and generate the *.box file.

Done with:

"post-processors": [
    [
      {
        "output": "builds/devbox.box",
        "type": "vagrant"
      }
    ]
  ]
Tomasnorre
  • 411
  • 2
  • 13