如何在导出/打包的盒子上保存共享/同步的 vagrant 目录中的内容?

如何在导出/打包的盒子上保存共享/同步的 vagrant 目录中的内容?

我正在尝试将使用 vagrant 创建的计算机导出为 Virtualbox 的 OVA 文件或托管在 vagrantcloud 中的包。计算机导出成功,但当我启动它时,应该包含我的文件的共享目录是空的。这看起来像是一个无知菜鸟的问题。

为什么启动导出的虚拟机时“/usr/local/fieldpapers/”是空的?导出后,我该怎么做才能保留该目录中的文件?

流浪文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.synced_folder "./", "/usr/local/fieldpapers/", id: "vagrant-root",
    owner: "vagrant",
    group: "www-data",
    mount_options: ["dmode=775,fmode=664"]

  config.vm.provider :virtualbox do |vb, override|
    vb.memory = 1024
    vb.cpus = 1
    vb.name = "Field Papers"
    override.vm.box = "precise64"
    override.vm.box_url = "http://files.vagrantup.com/precise64.box"
    override.vm.network :private_network, ip: "192.168.33.10"
    override.vm.provision :ansible, :playbook => "provisioning/playbook.yml"
  end
end

答案1

好的,我知道了!

关键部分是使用类型:“rsync” 前任:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.synced_folder "./", "/usr/local/fieldpapers/", id: "vagrant-root",
    owner: "vagrant",
    group: "www-data",
    type: "rsync",
    mount_options: ["dmode=775,fmode=664"]

  config.vm.provider :virtualbox do |vb, override|
    vb.memory = 1024
    vb.cpus = 1
    vb.name = "Field Papers"
    override.vm.box = "precise64"
    override.vm.box_url = "http://files.vagrantup.com/precise64.box"
    override.vm.network :private_network, ip: "192.168.33.10"
    override.vm.provision :ansible, :playbook => "provisioning/playbook.yml"
  end
end

相关内容