Timothy Pulliam
Timothy Pulliam

Reputation: 142

Vagrant Synced Folder without reload?

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.

Edit:

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"}}}

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

Upvotes: 6

Views: 2425

Answers (2)

Levon
Levon

Reputation: 11922

According to this issue on github the fastest solution is to use geerlingguy/centos7 box.

This box will build the guest additions.

Tested - works smoothly!

Upvotes: 2

Frederic Henri
Frederic Henri

Reputation: 53713

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

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

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"

Upvotes: 7

Related Questions