gstj4q
Last Updated: February 25, 2016
·
647
· michalbryxi

Password-less vagrant NFS share

NFS used in vagrant enviromnets is great when you are dealing with anything but small shares from host to guest. NFS synced folders needs root permissions when changing host setup. And it's not nice to be prompted for password every time i run vagrant up. Following record in sudoers file helps on MacOSX and Vagrant ≧ 1.3.x. Just run:

sudo visudo

from your shell. And then enter following:

Cmnd_Alias VAGRANT_EXPORTS_ADD = /bin/bash -c echo '*' >> /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%staff ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE