Posted at

MacでVagrant使うときいつも/etc/sudoersに書くやつ

More than 1 year has passed since last update.

NFS マウントと hostsupdater プラグインを使うときパスワードを入力しなくてもいいようにするには以下を /etc/sudoers に追記。


/etc/sudoers

    :

:

# Allow passwordless startup of Vagrant when using NFS.
# https://gist.github.com/joemaller/6764700
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE

# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
# https://github.com/cogitatio/vagrant-hostsupdater#linuxos-x-passwordless-sudo
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts
%admin ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE