Parallels / vagrant-parallels

Vagrant Parallels Provider
https://parallels.github.io/vagrant-parallels
MIT License
996 stars 87 forks source link

Plugin seems to ignore the nfs_export option for config.vm.synced_folder #336

Closed wizonesolutions closed 4 years ago

wizonesolutions commented 5 years ago

Vagrant allows this if we don't want the /etc/exports file edited: https://www.vagrantup.com/docs/synced-folders/nfs.html#nfs-synced-folder-options

However, Vagrant Parallels either doesn't pass this option on or doesn't implement it (I'm not clear who's responsible for this actual edit).

Here's some info-level logging that I was using to check if the setting was actually set:

==> snip2: Exporting NFS shared folders...
 INFO host: Execute capability: nfs_export [#<Vagrant::Environment: /Users/kevin/vhosts/snip3/snip>, #<Vagrant::UI::Prefixed:0x00000001022832c0 @logger=#<Log4r::Logger:0x0000000102283220 @fullname="vagrant::ui::interface", @outputters=[], @additive=true, @name="interface", @path="vagrant::ui", @parent=#<VagrantLogger:0x00000001020cbc20 @fullname="vagrant", @outputters=[#<Log4r::StderrOutputter:0x00000001010e4050 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0000000100923fa0>, @name="stderr", @level=0, @formatter=#<Vagrant::Util::LoggingFormatter:0x0000000102a69d18 @formatter=#<Log4r::BasicFormatter:0x000000010295b2c8 @depth=7>>, @out=#<IO:<STDERR>>>], @additive=true, @name="vagrant", @path="", @parent=#<Log4r::RootLogger:0x00000001020cb7c0 @level=0, @outputters=[]>, @level=2, @trace=false>, @level=2, @trace=false>, @opts={}, @stdin=#<IO:<STDIN>>, @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>, @prefix=:snip2, @ui=#<Vagrant::UI::Colored:0x0000000102370160 @logger=#<Log4r::Logger:0x0000000102370110 @fullname="vagrant::ui::interface", @outputters=[], @additive=true, @name="interface", @path="vagrant::ui", @parent=#<VagrantLogger:0x00000001020cbc20 @fullname="vagrant", @outputters=[#<Log4r::StderrOutputter:0x00000001010e4050 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0000000100923fa0>, @name="stderr", @level=0, @formatter=#<Vagrant::Util::LoggingFormatter:0x0000000102a69d18 @formatter=#<Log4r::BasicFormatter:0x000000010295b2c8 @depth=7>>, @out=#<IO:<STDERR>>>], @additive=true, @name="vagrant", @path="", @parent=#<Log4r::RootLogger:0x00000001020cb7c0 @level=0, @outputters=[]>, @level=2, @trace=false>, @level=2, @trace=false>, @opts={:color=>:default}, @stdin=#<IO:<STDIN>>, @stdout=#<IO:<STDOUT>>, @stderr=#<IO:<STDERR>>, @lock=#<Thread::Mutex:0x0000000100a5d7e0>>>, "64ebe416-5f8b-4eed-b5e4-99e575516a30", ["10.211.55.238"], {"/vagrant"=>{:type=>:nfs, :rsync__exclude=>nil, :rsync__args=>["--verbose", "--archive", "--delete", "-z", "--copy-links", "--chmod=ugo=rwX"], :id=>nil, :create=>false, :mount_options=>[], :nfs_udp=>false, :guestpath=>"/vagrant", :hostpath=>"/Users/kevin/vhosts/snip3/snip", :disabled=>false, :__vagrantfile=>true, :map_uid=>502, :map_gid=>20, :nfs_version=>3, :uuid=>"1178772757"}}] (darwin)
 INFO host: Execute capability: nfs_exports_template [#<Vagrant::Environment: /Users/kevin/vhosts/snip3/snip>] (darwin)
 INFO host: Execute capability: nfs_restart_command [#<Vagrant::Environment: /Users/kevin/vhosts/snip3/snip>] (darwin)
 INFO subprocess: Starting process: ["/sbin/nfsd", "checkexports"]
 INFO subprocess: Command not in installer, restoring original environment...
 INFO bsd: Exporting the following for NFS...
 INFO bsd: NFS DIR: ["/Users/kevin/vhosts/snip3/snip"]
 INFO bsd: NFS OPTS: {:type=>:nfs, :rsync__exclude=>nil, :rsync__args=>["--verbose", "--archive", "--delete", "-z", "--copy-links", "--chmod=ugo=rwX"], :id=>nil, :create=>false, :mount_options=>[], :nfs_udp=>false, :guestpath=>"/vagrant", :hostpath=>"/Users/kevin/vhosts/snip3/snip", :disabled=>false, :__vagrantfile=>true, :map_uid=>502, :map_gid=>20, :nfs_version=>3, :uuid=>"1178772757", :bsd__nfs_options=>["alldirs", "mapall=502:20"], :bsd__compiled_nfs_options=>"-alldirs -mapall=502:20"}
 INFO interface: info: Preparing to edit /etc/exports. Administrator privileges will be required...
 INFO interface: info: ==> snip2: Preparing to edit /etc/exports. Administrator privileges will be required...
==> snip2: Preparing to edit /etc/exports. Administrator privileges will be required...
 INFO environment: Released process lock: nfs-export
 INFO environment: Acquired process lock: dotlock
 INFO environment: Released process lock: dotlock
 INFO interface: info: Mounting NFS shared folders...
 INFO interface: info: ==> snip2: Mounting NFS shared folders...
==> snip2: Mounting NFS shared folders...
 INFO ssh: SSH is ready!
 INFO ssh: Execute:  (sudo=false)
 INFO ssh: SSH is ready!
 INFO ssh: Execute:  (sudo=false)
 INFO guest: Execute capability: mount_nfs_folder [#<Vagrant::Machine: snip2 (VagrantPlugins::Parallels::Provider)>, "10.211.55.2", {"/var/www/snip2"=>{:type=>:nfs, :rsync__exclude=>nil, :rsync__args=>["--verbose", "--archive", "--delete", "-z", "--copy-links", "--chmod=ugo=rwX"], :id=>nil, :create=>false, :mount_options=>[], :nfs_udp=>false, :nfs_export=>false, :guestpath=>"/var/www/snip2", :hostpath=>"/Users/kevin/vhosts/snip3/snip", :disabled=>false, :__vagrantfile=>true, :map_uid=>502, :map_gid=>20, :nfs_version=>3, :uuid=>"1178772757"}, "/vagrant"=>{:type=>:nfs, :rsync__exclude=>nil, :rsync__args=>["--verbose", "--archive", "--delete", "-z", "--copy-links", "--chmod=ugo=rwX"], :id=>nil, :create=>false, :mount_options=>[], :nfs_udp=>false, :guestpath=>"/vagrant", :hostpath=>"/Users/kevin/vhosts/snip3/snip", :disabled=>false, :__vagrantfile=>true, :map_uid=>502, :map_gid=>20, :nfs_version=>3, :uuid=>"1178772757"}}] (ubuntu)
 INFO ssh: Execute: mkdir -p /var/www/snip2 (sudo=true)
 INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
 INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-RMYSGVXhc3/agent.2039
 INFO ssh: Execute: mount -o vers=3 10.211.55.2:/Users/kevin/vhosts/snip3/snip /var/www/snip2 (sudo=true)
 INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
 INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-RMYSGVXhc3/agent.2039
 INFO retryable: Retryable exception raised: #<Vagrant::Errors::NFSMountFailed: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3 10.211.55.2:/Users/kevin/vhosts/snip3/snip /var/www/snip2

Stdout from the command:

Stderr from the command:

mount.nfs: access denied by server while mounting 10.211.55.2:/Users/kevin/vhosts/snip3/snip
>
 INFO ssh: Execute: mount -o vers=3 10.211.55.2:/Users/kevin/vhosts/snip3/snip /var/www/snip2 (sudo=true)
 INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
 INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-RMYSGVXhc3/agent.2039
 INFO retryable: Retryable exception raised: #<Vagrant::Errors::NFSMountFailed: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3 10.211.55.2:/Users/kevin/vhosts/snip3/snip /var/www/snip2

Stdout from the command:

Stderr from the command:

mount.nfs: access denied by server while mounting 10.211.55.2:/Users/kevin/vhosts/snip3/snip
>
 INFO ssh: Execute: mount -o vers=3 10.211.55.2:/Users/kevin/vhosts/snip3/snip /var/www/snip2 (sudo=true)
 INFO ssh: Execute: echo; printf $SSH_AUTH_SOCK (sudo=false)
 INFO ssh: Setting SSH_AUTH_SOCK remotely: /tmp/ssh-RMYSGVXhc3/agent.2039
ERROR warden: Error occurred: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3 10.211.55.2:/Users/kevin/vhosts/snip3/snip /var/www/snip2

Stdout from the command:

Stderr from the command:

mount.nfs: access denied by server while mounting 10.211.55.2:/Users/kevin/vhosts/snip3/snip

 INFO warden: Beginning recovery process...

The relevant Vagrantfile snippet (it's from geerlingguy/drupalvm) looks like:

  # Synced folders.
  vconfig['vagrant_synced_folders'].each do |synced_folder|
    options = {
      type: synced_folder.fetch('type', vconfig['vagrant_synced_folder_default_type']),
      rsync__exclude: synced_folder['excluded_paths'],
      rsync__args: ['--verbose', '--archive', '--delete', '-z', '--copy-links', '--chmod=ugo=rwX'],
      id: synced_folder['id'],
      create: synced_folder.fetch('create', false),
      mount_options: synced_folder.fetch('mount_options', []),
      nfs_udp: synced_folder.fetch('nfs_udp', false)
    }
    synced_folder.fetch('options_override', {}).each do |key, value|
      options[key.to_sym] = value
    end
    config.vm.synced_folder synced_folder.fetch('local_path'), synced_folder.fetch('destination'), options
  end

I have confirmed that nfs_export is actually getting set to Ruby false.

The logs above suggest that the nfs_export option isn't visible to Vagrant when it's deciding whether to edit /etc/exports or not, but that doesn't really make any sense given how the Vagrantfile works...

legal90 commented 4 years ago

@wizonesolutions Sorry for the super-late response :).

The provider doesn't change any settings related to upstream synced folders (like NFS), so it goes directly to Vagrant. If the issue still actual - I would suggest to search Vagrant issues for that (https://github.com/hashicorp/vagrant/).

But first I would make sure that your Vagrantfile actually has nfs_export option set to false explicitly. Your snipped doesn't have it, so it seems Vagrant treats is as true by default.

The option itself should work fine, as people say: https://github.com/hashicorp/vagrant/issues/11209#issuecomment-557102899