We have several vagrant boxes in our company and their Vagrantfiles Currently are very similar, the minimal code reproducing the issue I'm dealing with is
Vagrant.configure("2") do |config|
config.vm.box = "some_box_name"
case RbConfig::CONFIG['host_os']
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
config.vm.box_url = "file:////smbhost.ourintra.net/VagrantBoxes/" + config.vm.box + ".json"
when /darwin|mac os/
config.vm.box_url = "file:///Volumes/VagrantBoxes/" + config.vm.box + ".json"
else
config.vm.box_url = "file:///media/VagrantBoxes/" + config.vm.box + ".json"
end
config.vm.network :public_network
end
the some_box_name.json will have link to the actual .box file:
{
"name":"some_box_name",
"versions":[
{
"version":"1.1337",
"status":"active",
"providers":[
{
"name":"virtualbox",
"url":"http://httphost.ourintra.net/Public/VagrantBoxes/some_box_name-1337.box"
}
]
}
]
}
The solution above works for me and my colleagues, but I don't like to mount VagrantBoxes every time and I believe there should be more elegant ways, so I've tried to reference the json by http (it lies near .box files on httphost):
Vagrant.configure("2") do |config|
config.vm.box = "some_box_name"
config.vm.box_url = "http://httphost.ourintra.net/Public/VagrantBoxes/" + config.vm.box + ".json"
config.vm.network :public_network
end
And this solution isn't working:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'some_box_name' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'some_box_name' (v0) for provider: virtualbox
default: Downloading: http:/httphost.ourintra.net/Public/VagrantBoxes/some_box_name.json
The box failed to unpackage properly. Please verify that the box
file you're trying to add is not corrupted and that enough disk space
is available and then try again.
The output from attempting to unpackage (if any):
bsdtar: Error opening archive: Unrecognized archive format
I believe vagrant thinks I'm trying to provide it with direct .box url, but I don't want to do it, because box file names are changed in every build and .json names are static. Is it possible to fix this by changes to Vagrantfiles without much changes to remote files layout?
I found an answer in the similar question on superuser, my problem was in Content-Type returned by webserver. Solution:
Content-Type: application/json