winnfsd / vagrant-winnfsd

Manage and adds support for NFS for Vagrant on Windows.
Other
567 stars 62 forks source link

Options are not populated when calling nfsservice.bat #93

Closed amontalban closed 8 years ago

amontalban commented 8 years ago

Hey guys,

I have been trying to find out what's going on with this but my Ruby skills are minimum.

So far I found that with the following config:

    elsif ((/mswin|msys|mingw|cygwin|bccwin|wince|emc/ =~ RUBY_PLATFORM) != nil)
      config.winnfsd.uid = 80
      config.winnfsd.gid = 80
      config.vm.synced_folder "#{code_path}", "/usr/local/www/code",
      :nfs => true,
      :nfs_udp => true,
      :mount_options => ['nolockd,nfsv3,udp,noatime,actimeo=2,async']
    end

The nfsservice.bat is still called with UID/GID 0. If I modify the following code in lib/vagrant-winnfsd/config/winnfsd.rb:

      def finalize!
        @logging = 'off'  if @logging == UNSET_VALUE
        @uid = 0          if @uid == UNSET_VALUE
        @gid = 0          if @gid == UNSET_VALUE
        @host_ip = ""     if @host_ip == UNSET_VALUE
      end

And configure settings there they are populated when calling nfsservice.bat so it seems that the settings are not loaded properly.

Let me know if you need anything to test.

Thanks!

marcharding commented 8 years ago

Hey,

it works for me, maybe the problem is https://github.com/winnfsd/vagrant-winnfsd/blob/master/lib/vagrant-winnfsd/cap/nfs.rb#L36?

Try killing winnfsd.exe then run vagrant up again, does it work then?

amontalban commented 8 years ago

Hey @marcharding,

Yeah I killed the winnfsd.exe and tried several times but could not make it work. I'm using a bundle of latest winnfsd.exe built from source + your vagrant-winnfsd maybe that's the problem.

https://packagecloud.io/amontalban/vagrant-winnfsd/packages/gems/vagrant-winnfsd-1.1.0.gem

Let me try to test with the official Gem to confirm it works there.

Thanks!

amontalban commented 8 years ago

Ok I found the issue, I build a custom Packer box from ISO that I then export to Vagrant.

In that box I add the config lines and those are not read by the plugin (But if I put that config in the Vagrantfile that is created with vagrant init it does work properly).

Any idea of how can I make it work? The goal is that end user does not have to do anything.

Thank you very much!

amontalban commented 8 years ago

Hi @marcharding,

Here is some debug information:

        unless self.nfs_running?
          puts "#{env.to_yaml}"
          gid = env.vagrantfile.config.winnfsd.gid
          uid = env.vagrantfile.config.winnfsd.uid
          logging = env.vagrantfile.config.winnfsd.logging
          system("#{@nfs_start_command} #{logging} \"#{@nfs_path_file}\" #{uid} #{gid}")
          sleep 2
        end
screen shot 2016-06-23 at 5 48 27 pm

As you can check in [1] the uid and gid settings appears twice ( 0 which is default and 80 which is what I define in Vagrantfile in the basebox folder), so the problem seems to be that those values are not merged [3].

Let me know if you need anything else.

Thanks!

[1] https://gist.github.com/amontalban/9f84556ccdc73427b704b5f61dd23550 [2] https://gist.github.com/amontalban/ee1f03142837498d2e8cf5b20e6183b7 [3] https://www.vagrantup.com/docs/plugins/configuration.html#merging

amontalban commented 8 years ago

Hi @marcharding

Sorry to bother you with this but did you have time to check this issue? I'm banging my head against the wall with this and can't find the way to get it working properly.

Thanks!

marcharding commented 8 years ago

Hey, i just took a look.

With the vagrantfile and the current winnfsd-plugin (1.2.0) you provided it works for me..

Which vagrant version are you using? The lastet 1.8.4?

Edit: I'm using the freebsd/freebsd-10.2-release box.

amontalban commented 8 years ago

Hey,

It only works if you config settings in the local Vagrantfile but not in the base box Vagrantfile for example.

Can you try to do the following:

1) vagrant init 2) Configure winnfsd in your basebox Vagrantfile (Not in the created Vagrantfile in step 1). For example in my case it is C:\Users\IEUser\.vagrant.d\boxes\ubuntu-VAGRANTSLASH-trusty64\20160602.0.0\virtualbox\Vagrantfile 3) vagrant up

When you do vagrant up the ID is not the one you set in basebox Vagrantfile it's always 0 (The default).

I'm using latest winnfsd plugin and Vagrant.

EDIT: This can be handy to explain what I'm saying: https://www.vagrantup.com/docs/vagrantfile/#load-order-and-merging

Thanks!

marcharding commented 8 years ago

Hm, that also works for me.

I just put

Vagrant.configure(2) do |config|
  config.winnfsd.uid = 80
  config.winnfsd.gid = 80
end

into C:\Users{USERNAME}.vagrant.d\boxes\ubuntu-VAGRANTSLASH-trusty64\20160621.0.0\virtualbox\Vagrantfile

marcharding commented 8 years ago

Sorry i already had an instance running, can confirm it doesn't work.

marcharding commented 8 years ago

Okay, the merging is okay (@uid at https://github.com/winnfsd/vagrant-winnfsd/blob/master/lib/vagrant-winnfsd/config/winnfsd.rb#L30 is 80).

I not quite sure (until now i did i mostly work on winnfsd.exe), but i think the problem is that the merged variable is not used here https://github.com/winnfsd/vagrant-winnfsd/blob/master/lib/vagrant-winnfsd/cap/nfs.rb#L40.

amontalban commented 8 years ago

Hi,

You are right, thats the issue. To be more precisely the problem is here:

https://github.com/winnfsd/vagrant-winnfsd/blob/master/lib/vagrant-winnfsd/cap/nfs.rb#L37-L39

If we use env.vagrantfile we can have two vagrantfiles (And we are reading local one because is the last in the tree and it's defaulting to 0). If we could access the merged machine.config.winnfsd.uid value or access a @config handler would be great.

Maybe this plugin can be handy to see how they solved it:

https://github.com/mitchellh/vagrant/tree/master/plugins/provisioners/puppet

Thanks!

marcharding commented 8 years ago

Try this https://github.com/marcharding/vagrant-winnfsd/commit/172b24db98fc7317f195469cc5d303a822205ab5

amontalban commented 8 years ago

Hey @marcharding worked like a charm!!! You are a life saver.

Looking forward to see that merged in master.

Thank you!