devopsgroup-io / vagrant-digitalocean

:droplet: A Vagrant provider plugin that manages DigitalOcean droplets.
Mozilla Public License 2.0
1.71k stars 182 forks source link

rsync doesn't sync back to the host machine? #228

Closed shaharsol closed 8 years ago

shaharsol commented 8 years ago

my Vagrantfile:

config.vm.hostname = 'dropletname.example.com'
  # Alternatively, use provider.name below to set the Droplet name. config.vm.hostname takes precedence.

  config.vm.provider :digital_ocean do |provider, override|
    override.ssh.private_key_path = '~/.ssh/id_rsa'
    override.vm.box = 'digital_ocean'
    override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"

    provider.token = '{my token here}'
    provider.image = 'ubuntu-14-04-x64'
    provider.region = 'nyc2'
    provider.size = '512mb'
  end

  config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__auto: true

  #config.vm.box = "hashicorp/precise64"
  config.vm.provision :shell, path: "bootstrap.sh"

after I run vagrant up I then vagrant ssh to the machine at Digital Ocean, where I cd /vagrant and then tough foo. a simple ls foo then shows me the new file. However, back in the host machine a simple ls foo says no such file or directory. I tried a manual vagrant rsync and it doesn't seem to do anything as well.

Anything I'm doing wrong?

davidalger commented 8 years ago

@shaharsol Synced folders (of the rsync type) are a one-way sync. See the following from the official vagrant documentation: https://www.vagrantup.com/docs/synced-folders/rsync.html

The rsync synced folder does a one-time one-way sync from the machine running to the machine being started by Vagrant.

To my knowledge, this is no easy way to setup a two-way sync with Digital Ocean backed machines (or AWS for that matter). I've been playing with this stuff a lot lately, and haven't come up with a good solution myself yet, other than building something that sits alongside vagrant or creating my own vagrant plugin.

shaharsol commented 8 years ago

@davidalger Oh I'm new to vagrant, just through with the getting started where they show how you touch a file on the guest system and it's reflected on the hosting system via synced folders. I thought I could expect this type of behaviour from any provider.

So what are my options, assuming my goal is to have files created on the guest system in DigitalOcean being synced back to the hosting system? maybe NFS?

davidalger commented 8 years ago

@shaharsol On a local provider such as virtual box or vmware, such is the case by default because synced folders use the virtual box or vmware file sharing system to essentially "mount" local files in the guest. NFS or SMB also accomplish the same thing. Since Digital Ocean is remote, synced folder types are more limited. I haven't personally tried doing NFS, but I doubt it's supported, as read/write performance on the guest would be terrible and would require your machine stay online to work. You might try them, but I doubt it will work well if it even functions at all :) Beyond that, I don't really have any good solution for a two-way sync.