New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounting nfs requires sudo, but the sudoers file given in documentation no longer works. #6022

Closed
Mihara opened this Issue Jul 22, 2015 · 13 comments

Comments

Projects
None yet
@Mihara

Mihara commented Jul 22, 2015

After upgrading to Vagrant 1.7.4, the following sudoers file, given in the documentation, no longer produces the desired result on Ubuntu 14.04:

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

Running vagrant up --debug, unfortunately, results in no hints on what command it actually wants to run, so I find it quite difficult to figure out what do I need to do to make it work again.

It worked in 1.7.2.

@narkisr

This comment has been minimized.

narkisr commented Jul 27, 2015

Confirmed on 14.10, looking at /var/log/auth.log I don't see the failing command either

@narkisr

This comment has been minimized.

narkisr commented Jul 27, 2015

Iv tracked this to a series of commits done on nfs.rb while solving this issue, it seems that the exports remove has changed and new cp command added.

Still I'm unable to produce a working sudoers entry to fix this

@narkisr

This comment has been minimized.

narkisr commented Jul 27, 2015

I think that iv managed to find a working solution:

ֻCmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_EXPORTS_COPY = /bin/cp /tmp/exports /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 /tmp/exports
%sudo ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY, VAGRANT_EXPORTS_REMOVE, VAGRANT_EXPORTS_COPY

Iv added a copy and changed the sed remote command

@Mihara

This comment has been minimized.

Mihara commented Jul 28, 2015

Confirmed, it works. Thanks for figuring this one out.

@emodric

This comment has been minimized.

emodric commented Jul 30, 2015

I've tried this in 1.7.4 on Ubuntu 15.04 and sadly it doesn't work :(

@demoray

This comment has been minimized.

demoray commented Aug 26, 2015

the sed line should not need sudo privileges, as it is writing to a temp file.

@andrewmackrodt

This comment has been minimized.

andrewmackrodt commented Sep 3, 2015

Thanks for your fix @narkisr, confirmed working with vagrant 1.7.4 and Ubuntu 14.04.02

@pm98zz-c

This comment has been minimized.

pm98zz-c commented Sep 8, 2015

@narkisr Works for me too on Debian (Stretch).

@aosmialowski

This comment has been minimized.

aosmialowski commented Sep 19, 2015

Weird, but @narkisr solution does not work for me on Ubuntu 14.04 LTS.

@nathanielks

This comment has been minimized.

Contributor

nathanielks commented Nov 24, 2015

Woohoo! Thanks @sethvargo!

@dklotz

This comment has been minimized.

dklotz commented Mar 1, 2016

The commands given in the documentation still do not work for me on OS X. They used to, but they stopped working (i.e. now require a password again) somewhere around 1.7.x...

@guysoft

This comment has been minimized.

guysoft commented Mar 2, 2016

Not working for me on debian jessie

@karlingen

This comment has been minimized.

karlingen commented Mar 15, 2016

For future googlers:
Se the section ROOT PRIVILEGE REQUIREMENT in the docs: https://www.vagrantup.com/docs/synced-folders/nfs.html

Managed to solve this on my mac by adding proper lines to my /etc/sudoers file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment