是否有可能使用Packer对在我的本地计算机上完全创建/托管的盒子进行版本控制而不将其发布在HashiCorp Atlas上?当我执行vagrant box list时,我得到如下内容:

vagrant box list
Win8        (virtualbox, 0)
dummy       (aws, 0)

在最后一列中显示了包装盒的版本。我希望能够在打包过程中更改该数字。他们的文档似乎暗示我只能通过使用Atlas来获得此功能:

最佳答案

通过模仿Vagrant对HashiCorp Atlas API的期望,可以实现此目的。创建一个JSON文件,其中包括其API文档(VagrantUp上的here和Atlas上的here)中提到的相关框元数据:

{
  "description": "A long description of your box.",
  "short_description":"Short description",
  "name": "yourname/boxname",
  "versions": [
    {
      "version": "1.0.0",
      "status":"revoked",
      "description_html":null,
      "description_markdown":null,
      "created_at" : "2015-08-13T07:39:00.000Z",
      "updated_at" : "2015-08-13T07:39:00.000Z",
      "providers": [
        {
          "checksum": "foo",
          "checksum_type": "md5",
          "name": "virtualbox",
          "url": "file:////192.168.1.1/Vagrant/ubuntu-14-04-x64-virtualbox-1.0.0.box"
        }
      ]
    },
    {
      "version": "1.1.0",
      "status":"active",
      "description_html":null,
      "description_markdown":null,
      "created_at" : "2015-08-15T19:05:00.000Z",
      "updated_at" : "2015-08-15T19:05:00.000Z",
      "providers": [
        {
          "checksum": "bar",
          "checksum_type": "md5",
          "name": "virtualbox",
          "url": "file:////192.168.1.1/Vagrant/ubuntu-14-04-x64-virtualbox-1.1.0.box"
        }
      ]
    }
  ]
}

将其另存为boxname.json(我认为这不是必需的,但是我相信这是Atlas约定)。然后像这样从您的Vagrantfile调用它
# Enable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
config.vm.box_check_update = true

# The path to the box metadata file
config.vm.box = "yourname/boxname"
config.vm.box_url = "file://./boxname.json"

关于vagrant - 本地Packer Box版本控制,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31952257/

10-10 18:20