mitchellh / vagrant-aws

Use Vagrant to manage your EC2 and VPC instances.
MIT License
2.61k stars 574 forks source link

rsync on provision #504

Closed janschumann closed 7 years ago

janschumann commented 7 years ago

According to https://github.com/janschumann/vagrant-aws#synced-folders, folders will be synced on up, reload and provision actions. But for provision the SyncedFolders task was missing.

When placing b2.use SyncedFolders before b2.use Provision the folder sync is executed AFTER provisioning. Is that intended? Nevertheless I placed it after provisioning and now it works correctly.

tonybajan commented 7 years ago

We've recently found that this used to be the behaviour in 0.6.0, but it regressed in 0.7.0.

janschumann commented 7 years ago

@ColinHebert could you please tell us why you decided to regress this feature in 0.7? Does it have any side effects?

ColinHebert commented 7 years ago

As per https://github.com/mitchellh/vagrant-aws/pull/347 and https://www.vagrantup.com/docs/synced-folders/rsync.html

Without running these commands, Vagrant only syncs the folders on vagrant up or vagrant reload.

Overall for consistent and documented behaviour.

ColinHebert commented 7 years ago

To expand on my previous answer. The initial behaviour was to sync only on vagrant up and vagrant reload. On vagrant up it makes sense because otherwise there is nothing to provision in the first place. vagrant reload is meant to be a full reload of the machine, so syncing again makes perfect sense.

vagrant provision on the other hand is meant to run the provisioning part assuming that the files are already there from a previous sync (on up or reload). And it is, by design, possible to provision the same content multiple times without having new data. It doesn't require any extra operations (upload or otherwise) than running the provisioning (ie. does what it says on the tin). On the other hand if we do synchronise before a provision, or at any other point in time, we break this contract of "sync only at given times" and also introduce a behaviour different from the "provision only provisions": https://github.com/mitchellh/vagrant/blob/b223380/plugins/providers/virtualbox/action.rb#L171 https://github.com/mitchellh/vagrant/blob/b223380/plugins/providers/docker/action.rb#L53 (and so on).

The best thing to do is to either create a new action (provision_sync or something like that), use vagrant rsync-auto or simply run two commands (as it's been initially designed): vagrant rsync && vagrant provision.

My recommendation being the second one which is specifically there for this particular use-case.

janschumann commented 7 years ago

@ColinHebert thanks. Actually an rsync command was what I was initially looking for. But it does not show up on vagrant -h, so I refused to read the docs and tried my own solution. Also because the vagrant-aws docs document another behaviour: https://github.com/janschumann/vagrant-aws#synced-folders,

janschumann commented 7 years ago

The rsync command actually shows up in vagrant list-commands. Thanks!