我们公司有几个流浪盒和他们的Vagrantfile s 目前非常相似,再现我正在处理的问题的最小代码是
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
some_box_name.json将链接到实际的.box文件:
{
"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"
}
]
}
]
}
上面的解决方案适用于我和我的同事,但我不喜欢每次都安装VagrantBoxes,我相信应该有更优雅的方式,所以我试图通过http引用json(它靠近。 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
此解决方案无效:
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
我相信vagrant认为我正在尝试为它提供直接的.box网址,但我不想这样做,因为每个版本都会更改框文件名,而.json名称是静态的。是否可以通过更改Vagrantfile s 来解决此问题,而无需对远程文件布局进行太多更改?
答案 0 :(得分:0)
我找到了答案in the similar question on superuser,我的问题出在网络服务器返回的Content-Type中。解决方案:
Content-Type: application/json