与配置文件共享vagrant

时间:2015-07-16 12:29:35

标签: vagrant vagrantfile

我刚刚完成了我的Vagrant盒子。

它有Gemfire和其他一些东西。该规定运行良好,但它有几个配置文件需要配合它。

如何以这些文件随身携带的方式共享我的盒子?

一个例子:

要启动Gemfire服务器,您需要一些区域配置,所以我希望我的项目区域在那里,以便它可以在准备开发状态下启动。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

听起来像Packer的一个功能。使用Packer将您的包装盒与Virtualbox构建器打包在一起。首先是我的例子然后我会解释这个功能。我正在使用这个packer.json打包我的流浪盒:

{
  "builders": [
    {
        "type": "virtualbox-ovf",
        "source_path": "Redistribution.ovf",
        "ssh_username": "vagrant",
        "ssh_password": "vagrant",
        "ssh_wait_timeout": "10000s",
        "headless": true,
      "guest_additions_mode": "disable",
        "vboxmanage": [
            ["modifyvm", "{{.Name}}", "--memory", "1024"],
            ["modifyvm", "{{.Name}}", "--cpus", "2"]
        ],
        "shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
      }
  ],
  "provisioners": [
        {
            "type": "shell",
            "script": "packer/putInsecureKey.sh"
        }
  ],
  "post-processors": [
    {
        "type":               "vagrant",
        "compression_level":  9,
      "output":             "vagrant-dockerdev.box"
      }
  ]
}

我已经安装了Packer 0.8.1并在导出的Vagrant框上运行此命令:

packer build packer.json

后处理器的以下参数会将文件放在可以由Vagrantfile引用的框中。请参阅Packer Documentation

  • include(字符串数组) - 要包含在Vagrant框中的文件的路径。这些文件将被复制到Vagrant框的顶级目录中(无论它们的路径如何)。然后可以从Vagrant文​​件中使用它们。

  • vagrantfile_template(string) - 用于随盒子打包的Vagrantfile的模板的路径。

现在回到我的例子:

"post-processors": [
    {
      "type":                 "vagrant",
      "compression_level":    9,
      "output":               "vagrant-dockerdev.box"
      "include":              ["path/to/file1", "path/to/file2"]
      "vagrantfile_template": "path/to/vagrant-template"
    }
]
相关问题