I have a vagrant box with chef provisioner. Everything works fine except when there are operation on NFS resources. For example, I have the following synced folders:
"host_path": "/Users/User/devbox/vdd/data",
"guest_path": "/var/www",
"type": "nfs"
And in the vagrant file:
# Synced Folders.
config_json["vm"]["synced_folders"].each do |folder|
case folder["type"]
when "nfs"
config.vm.synced_folder folder["host_path"], folder["guest_path"], type: "nfs"
# This uses uid and gid of the user that started vagrant.
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
and I also have a chef recipe that executes a create
action on an nfs resource:
directory "/var/www" do
owner "vagrant"
group "vagrant"
end
However, I keep getting the following error:
default: Error executing action `create` on resource 'directory[/var/www]'
==> default: ================================================================================
==> default:
==> default:
==> default: Errno::EPERM
==> default: ------------
==> default: Operation not permitted - /var/www
==> default:
==> default:
==> default: Resource Declaration:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef-3/chef-solo-2/cookbooks/vdd/recipes/apache.rb
==> default:
==> default: 1: directory "/var/www" do
==> default: 2: owner "vagrant"
==> default: 3: group "vagrant"
==> default: 4: end
==> default: 5:
==> default:
==> default:
==> default:
==> default:
==> default: Compiled Resource:
The only way to get rid of the problem (and keep the nfs) is by the following:
Change
nfs
todefault
.run
vagrant reload --provision
change
default
back tonfs
run
vagrant reload
I have search and tried various suggested solution but nothing worked for me thus far.
drwxr-xr-x 7 501 dialout 238 Jan 26 19:41 www
/ – awmnfs: true, :linux__nfs_options => ["no_root_squash", "rw","no_subtree_check"],:map_uid => 0, :map_gid => 0
but then the permissions and ownership are not right. – awm