Skip to content

Instantly share code, notes, and snippets.

@gamunu
Created May 19, 2017 05:16
Show Gist options
  • Save gamunu/95cad7b5f536e20f38843217443f3e51 to your computer and use it in GitHub Desktop.
Save gamunu/95cad7b5f536e20f38843217443f3e51 to your computer and use it in GitHub Desktop.
Using NFS shares from Vagrant without password prompts
# Allow Vagrant to manage /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD_CHECK = /usr/bin/systemctl status --no-pager nfs-server.service
Cmnd_Alias VAGRANT_NFSD_START = /usr/bin/systemctl start nfs-server.service
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /*/exports
Cmnd_Alias VAGRANT_EXPORTS_REMOVE_2 = /bin/cp /*/exports /etc/exports
%vagrant ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE, VAGRANT_EXPORTS_REMOVE_2
Afterwards add yourself to the vagrant group if you are not there already by running:
$ sudo getent group vagrant >/dev/null || sudo groupadd -r vagrant
$ sudo gpasswd -a ${USER} vagrant
$ newgrp vagrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment