无需重新加载的 Vagrant 同步文件夹? [英] Vagrant Synced Folder without reload?

查看:39
本文介绍了无需重新加载的 Vagrant 同步文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主机上有一个位于 ~/ansible/provisioning/playbook.yml 的文件,对应于来宾上的 /vagrant/provisioning/playbook.yml.每次我对主机上的文件进行更改时,这些更改都不会显示在来宾上,除非我运行 vagrant reload 完全重新启动 VirtualBox VM.是否有另一种方法可以使用另一种文件系统类型(可能是 NFS)实时同步文件?我的主机是 MacOS,来宾是 CentOS 7.我使用的是 vagrant 2.0.0 版.

I have a file on my host located at ~/ansible/provisioning/playbook.yml that corresponds to /vagrant/provisioning/playbook.yml on the guest. Every time I make changes to the file on the host, the changes do not show up on the guest unless I run vagrant reload which completely restarts the VirtualBox VM. Is there another way to get files to sync in real time using another filesystem type (NFS perhaps)? My host is MacOS, guest is CentOS 7. I am using vagrant version 2.0.0.

我已将我的 Vagrantfile 包含在 pastebin 上.是的,看来我正在使用 rsync.

I have included my Vagrantfile on pastebin. Yes, it appears I am using rsync.

$ cat .vagrant/machines/default/virtualbox/synced_folders 
{"rsync":{"/vagrant":{"type":"rsync","guestpath":"/vagrant","hostpath":"/Users/timothy/Desktop/code/ansible","disabled":false,"__vagrantfile":true,"owner":"vagrant","group":"vagrant"}}}

除了将 config.vm.synced_folder ".", "/vagrant", type: "virtualbox" 添加到我的 Vagrantfile 之外,我还必须运行$ vagrant plugin install vagrant-vbguest

In addtion to adding config.vm.synced_folder ".", "/vagrant", type: "virtualbox" to my Vagrantfile, I also had to run $ vagrant plugin install vagrant-vbguest

推荐答案

因为认为 rsync 是启用的,所以 centos/7 盒子默认有 rsync,这个已经讨论过 之前

as thought rsync is enabled, the box centos/7 has rsync by default, this has been discussed before

使用rsync时,可以打开rsync-auto命令自动将任何新更改从主机推送到 VM.

When using rsync, you can turn the rsync-auto command to automatically push any new changes from the host to the VM.

如果你想使用默认的虚拟盒子共享文件夹功能,你可以在你的 Vagrantfile 中添加以下内容

If you want to use default virtual box shared folder feature, you can add the following in your Vagrantfile

config.vm.synced_folder ".", "/vagrant", type: "virtualbox"

这篇关于无需重新加载的 Vagrant 同步文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆