Northys
Northys

Reputation: 1313

Cannot change file ownership from Vagrant VM

I have been using NFS mounts in my Vagrant VM for months without any problems running our puppet provisioning. As you can know each time you create folder using puppet you have to specify its owner and group otherwise defaults are used. We have set default to root:root for some reason and this is applied to some other files / directories as well.

Puppet trying to chown file to root:root and it fails but it should not because chown exits with 0 without changing the owner or group. This behavior is same on NFS and VirtualBox Share but puppet fails only when using NFS share.

The question is - is there any reasonable explanation why puppet has started to fail on changing ownership of files? It used to work for months and I'm still running the same version of Vagrant and VirtualBox.

I have found a lot of questions regarding similar problem (changing ownership) and found it is ok that owner and group is not changed. I just don't know why puppet fails because of this only on NFS.

Vagrantfile mount section

config.vm.synced_folder "../puppet", "/root/puppet", type: "nfs", mount_options: ["rw", "tcp", "fsc", "nolock", "noacl", "async"], nfs_udp: false
config.vm.synced_folder ".", "/media/src/project", type: "nfs", mount_options: ["rw", "tcp", "fsc", "nolock", "noacl", "async"], nfs_udp: false

Puppet log on NFS

Info: Applying configuration version '1471704237'
Notice: /Stage[main]/Farm_tooling::Webgrind/Exec[configure]/returns: executed successfully
Notice: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/owner: owner changed '501' to 'root'
Error: Failed to set group to '0': Operation not permitted @ lchown_internal - /media/src/ulozto/.local
Error: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/group: change from dialout to root failed: Failed to set group to '0': Operation not permitted @ lchown_internal - /media/src/ulozto/.local

Puppet log on VirtualBox share

Info: Applying configuration version '1471704248'
Notice: /Stage[main]/Farm_tooling::Webgrind/Exec[configure]/returns: executed successfully
Notice: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/owner: owner changed 'vagrant' to 'root'
Notice: /Stage[main]/Ulozto::Web::Lab/File[/media/src/ulozto/.local/]/group: group changed 'vagrant' to 'root'
Notice: /Stage[main]/Ulozto::Pornfile::Remote/File[/var/www/pornfile-web/PornFile/App]/owner: owner changed 'vagrant' to 'root'

Directory listing after puppet run on NFS

drwxr-xr-x  4  501 dialout    136 Aug 19 05:40 .local

I actually do not know what dialout is but 501 is ID of my account - uid=501(northys). After puppet run owner is still the same.

Directory listing after puppet run on VirtualBox share

drwxr-xr-x  1 vagrant vagrant    136 Aug 19 05:40 .local

After puppet run owner and group is still vagrant:vagrant but puppet didn't fail on changing it like in NFS mount case.

Upvotes: 1

Views: 2754

Answers (1)

Tobias Gaertner
Tobias Gaertner

Reputation: 1184

I found the answer for this here https://serverfault.com/questions/487862/vagrant-os-x-host-nfs-share-permissions-error-failed-to-set-owner-to-1000

In my VagrantFile, I added this to the mapping to get it to work:

:linux__nfs_options => ["no_root_squash"], :map_uid => 0, :map_gid => 0

Upvotes: 1

Related Questions