Vagrant 通过http获取漫游框定义

Vagrant 通过http获取漫游框定义,vagrant,vagrantfile,Vagrant,Vagrantfile,我们公司有几个流浪者的盒子,他们的流浪者文件目前非常相似,复制我正在处理的问题的最小代码是 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.ourint

我们公司有几个流浪者的盒子,他们的流浪者文件目前非常相似,复制我正在处理的问题的最小代码是

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"
            }
         ]
      }
   ]
}
上面的解决方案对我和我的同事都有效,但我不喜欢每次挂载VagrantBox,我认为应该有更优雅的方式,所以我尝试通过http引用json(它位于httphost上的.box文件附近):

而此解决方案不起作用:

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 url,但我不想这样做,因为在每次构建中,box文件名都会更改,.json名称是静态的。有没有可能在不改变远程文件布局的情况下通过更改文件来解决这个问题?

我找到了答案,我的问题是Web服务器返回的内容类型。解决方案:

Content-Type: application/json

为什么不能直接从Vagrantfile中读取Json,而只从Json中获取providers[url]值以提供给config.vm.box\u url?
Content-Type: application/json