This script automatically modifies /etc/sudoers
to allow commands like
vagrant up
to proceed without asking for your sudo password.
Supported features:
- NFS synced folders
- vagrant-hostsupdater
Tested with Vagrant 1.4.
Current version supports OS X only.
This script was inspired by and is based on Nick Muerdter's install_vagrant_sudoers.sh.
$ sudo ./vagrant-passwordless-sudo.sh
Password:
All done, vagrant should not ask for your sudo password anymore!
The following lines will be appended to your /etc/sudoers
:
##### BEGIN VAGRANT PASSWORDLESS SUDO #####
###
### Generated by vagrant-passworless-sudo, modify at your own risk!
###
# NFS commands
Cmnd_Alias VAGRANT_EXPORTS_ADD = /bin/bash -c echo '*' >> /etc/exports
Cmnd_Alias VAGRANT_NFSD_RESTART = /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_RESTART, VAGRANT_EXPORTS_REMOVE
# vagrant-hostsupdater commands
Cmnd_Alias VAGRANT_HOST_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOST_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts
%staff ALL=(root) NOPASSWD: VAGRANT_HOST_ADD, VAGRANT_HOST_REMOVE
##### END VAGRANT PASSWORDLESS SUDO #####
The script cleans after itself, so it's completely safe to re-run it at any time.