Is there a way for Vagrant to import a local box file with a specified version?
Solution 1:
Based on this answer, to specify a version for local boxes, you need to create a metadata.json
.
The minimum content of the file looks like this:
{
"name": "USERNAME/BOXNAME",
"versions": [{
"version": "X.Y.Z",
"providers": [{
"url": "package.box"
}]
}]
}
Where the package.box
is the relative path from metadata.json
After that, you can simply run vagrant box add metadata.json
to add a new box with a version.
Warning:
Vagrant stores the metadata.json
url in the ~/.vagrant.d/boxes/FULLBOXNAME/metadata_url
file. So, bee careful with names, you could't use the same name from different sources.
Solution 2:
after import your box file
cd ~/.vagrant.d/boxes/<username>-VAGANTSLASH-<boxname>/
mv 0 <specified version>