Reputation: 8911
I have a CentOS 7 vagrant. When I try to use nfs for sharing a folder the folder gets owned by the user 501 of the "games" group:
[vagrant@site-dev ~]$ ls -la
total 28
drwx-----x. 6 vagrant vagrant 180 feb 27 21:18 .
drwxr-xr-x. 3 root root 21 dic 15 11:14 ..
drwxrwxr-x. 3 vagrant vagrant 17 feb 24 17:46 .ansible
-rw-rw-r--. 1 vagrant vagrant 17 feb 27 20:46 app.php
-rw-------. 1 vagrant vagrant 4811 feb 27 21:47 .bash_history
-rw-r--r--. 1 vagrant vagrant 18 dic 6 23:19 .bash_logout
-rw-r--r--. 1 vagrant vagrant 193 dic 6 23:19 .bash_profile
-rw-r--r--. 1 vagrant vagrant 231 dic 6 23:19 .bashrc
-rwxrwxrwx. 1 vagrant vagrant 0 feb 27 20:49 index.html
drwxrwxr-x. 2 vagrant vagrant 78 feb 24 18:17 .phpstorm_helpers
drwx------. 2 vagrant vagrant 29 feb 24 17:45 .ssh
drwxrwxrwx. 22 501 games 748 feb 27 21:47 www
The strange thing is that if I remove the nfs option from the Vagrantfile then I don't have that problem (but performance drops)
Here's my Vagrantfile config without the nfs option
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 80, host: 8088
config.vm.network "private_network", ip: "192.168.56.150"
config.vm.hostname = "site-dev"
config.vm.synced_folder ".", "/home/vagrant/www"
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
config.vm.provision :ansible do |ansible|
ansible.playbook = "ansible/playbook.yml"
ansible.verbose = 'vvv'
ansible.inventory_path = "ansible/hosts"
ansible.limit = 'development'
end
end
Any idea why this is happening and how I can use nfs for the shared folder?
Upvotes: 2
Views: 1011
Reputation: 53793
It should not be much of an issue - Mitchell explains here
NFS works by simply shuttling files and metadata over from server to client, which means permissions can't be changed mid-way. I've configured NFS by default to the common-case, which is that even though the uid/gid is 501/20, every user on the VM should be able to write to it (go ahead, try it!).
In practice, this has never been a problem for serving any web applications.
If you really want to have correct username shows in ls
command you can look at the vagrant bindfs plugin
Upvotes: 0