Can I modify the ownership for a shared folder in vagrant?
@john-syrinek
in 1.2+
config.vm.synced_folder "src/", "/srv/website",
owner: "root", group: "root"
http://docs.vagrantup.com/v2/synced-folders/basic_usage.html
As @StephenKing suggests you can change the options of the whole directory.
The relevant function is not documented but the source tells us:
# File 'lib/vagrant/config/vm.rb', line 53
def share_folder(name, guestpath, hostpath, opts=nil)
@shared_folders[name] = {
:guestpath => guestpath.to_s,
:hostpath => hostpath.to_s,
:create => false,
:owner => nil,
:group => nil,
:nfs => false,
:transient => false,
:extra => nil
}.merge(opts || {})
end
Basically you can set group, owner and acl for the whole folder which is way better than setting everything to world writable on the host. I have not found any method to change the ownership of a nested directory.
Here is a quickfix:
config.vm.share_folder "v-wordpress", "/var/www/wordpress", "/host/path", :owner => "www-data", :group => "www-data"