Last active
December 31, 2021 11:30
-
-
Save elvetemedve/c3574e5cadbcddef0b85 to your computer and use it in GitHub Desktop.
Allow Vagrant usage without providing sudo password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo tee /etc/sudoers.d/vagrant > /dev/null << EOL | |
# | |
# Arch Linux, Fedora sudoers entries | |
# | |
# Allow passwordless startup of Vagrant with vagrant-hostsupdater. | |
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts | |
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts | |
%sudo ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE | |
# Allow passwordless startup of Vagrant with NFS synced folder option. | |
Cmnd_Alias VAGRANT_EXPOSTS_UPDATE = /usr/bin/chown 0\:0 /tmp/*, /usr/bin/mv -f /tmp/* /etc/exports | |
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports | |
Cmnd_Alias VAGRANT_NFSD_CHECK = /usr/bin/systemctl status nfs-server.service, /usr/sbin/systemctl status nfs-server.service | |
Cmnd_Alias VAGRANT_NFSD_START = /usr/bin/systemctl start nfs-server.service, /usr/sbin/systemctl start nfs-server.service | |
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/bin/exportfs -ar, /usr/sbin/exportfs -ar | |
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /tmp/exports, /usr/bin/cp /tmp/exports /etc/exports | |
%sudo ALL=(root) NOPASSWD: VAGRANT_EXPOSTS_UPDATE, VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE | |
EOL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo tee /etc/sudoers.d/vagrant > /dev/null << EOL | |
# | |
# OS X sudoers entries | |
# | |
# Allow passwordless startup of Vagrant with vagrant-hostsupdater. | |
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 | |
# Allow passwordless startup of Vagrant with NFS synced folder option. | |
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 | |
EOL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo tee /etc/sudoers.d/vagrant > /dev/null << EOL | |
# | |
# Ubuntu Linux sudoers entries | |
# | |
# Allow passwordless startup of Vagrant with vagrant-hostsupdater. | |
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts | |
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts | |
%sudo ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE | |
# Allow passwordless startup of Vagrant with NFS synced folder option. | |
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports | |
Cmnd_Alias VAGRANT_NFSD_CHECK = /etc/init.d/nfs-kernel-server status | |
Cmnd_Alias VAGRANT_NFSD_START = /etc/init.d/nfs-kernel-server start | |
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar | |
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /etc/exports | |
%sudo ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE | |
EOL |
The Arch Linux
Version doesn't work with Manjaro
Well, I've stopped using Vagrant years ago, so these scripts could be outdated. What you can do is read the source code of Vagrant and compare the commands executed via sudo and amend these command aliases accordingly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
Ubuntu Linux
Version does not work withDebian Buster
andVagrant 2.2.9
.