Closed kyletcook closed 3 years ago
@kyletcook yes, this can be quite annoying, this is something that vagrant does by default when using the host manager plugin. Follow the instructions below to remove the need of having the password dialog shown.
To avoid being asked for the password every time the hosts file is updated, enable password-less sudo for the specific command that host-manager uses to update the hosts file.
Add the following snippet to the sudoers file (e.g. /etc/sudoers.d/vagrant_hostmanager
):
# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
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_NFSD, VAGRANT_EXPORTS_ADD, VAGRANT_EXPORTS_REMOVE, VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
Problem / Motivation
User runs command
px env:up
During the process, after Vagrant has been launched, there is an interruption.command ==> ###: Preparing to edit /etc/exports. - requires passwd
Environment
Mac OS Mojave
Resolution
Ideally, process could be bypassed to complete the start of the environment without user intervention.