hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

Chef_solo-Provision does not mount synced folder via NFS #2749

Closed andygrunwald closed 10 years ago

andygrunwald commented 10 years ago

During a provisioning with Chef-Solo, a synced_folder will be created, to make the cookbooks available on guest machine. Since documentation it is possible to force this synced_folder to use NFS (chef.nfs = true).

If you use FreeBSD as GuestOS this is necessary, because FreeBSD does not support native synced_folders. The mentioned setting seems not to work as expected. Or did i / understand i something wrong?

Vagrant: 1.4.2 VirtualBox: 4.3.6 OS: Ubuntu 12.04

VagrantFile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "freebsd-9.1-64bit-chef"
  config.vm.guest = :freebsd
  config.vm.box_url = "http://dyn-vm.s3.amazonaws.com/vagrant/dyn-chef-11.4.0-virtualbox-freebsd-9.1.box"

  config.vm.network :private_network, ip: "192.168.33.10"

  config.vm.synced_folder ".", "/vagrant", type: "nfs"

  config.vm.provision :chef_solo do |chef|
      chef.nfs = true
      chef.cookbooks_path = "cookbooks"
      chef.add_recipe "sonar"
    end
end

Cheffile

#!/usr/bin/env ruby
#^syntax detection

site 'http://community.opscode.com/api/v1'

# Workaround for https://github.com/applicationsonline/librarian/issues/159
cookbook 'windows', 
    :git => 'https://github.com/SimpleFinance/chef-windows.git'

cookbook 'sonar',
    :git => 'https://github.com/TYPO3-cookbooks/sonar.git'

Vagrant up

vagrant up                                                                                                                                              ⮂ 08:55 ⮂ 14-01-03 
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'freebsd-9.1-64bit-chef'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.

Guest Additions Version: 4.2.12
VirtualBox Version: 4.3
[default] Configuring and enabling network interfaces...
[default] Exporting NFS shared folders...
Preparing to edit /etc/exports. Administrator privileges will be required...
nfsd running
[default] Mounting NFS shared folders...
[default] Mounting shared folders...
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
Vagrant attempted to execute the capability 'mount_virtualbox_shared_folder'
on the detect guest OS 'freebsd', but the guest doesn't
support that capability. This capability is required for your
configuration of Vagrant. Please either reconfigure Vagrant to
avoid this capability or fix the issue by creating the capability.

Can anyone reproduce this problem? Do you need further information?

mitchellh commented 10 years ago

This is fixed in git.

petecheslock commented 10 years ago

Any info on when a patch release would go out with the fix - or what sha this fix is in?

tmatilai commented 10 years ago

The fix is included in master which heads for 1.5.0, but that will probably take some more time.

I offer to backport this and some others (which ones?) if @mitchellh agrees to make one more 1.4.x release.

petecheslock commented 10 years ago

That would be a huge help if 1.5 is going to be a while yet. We use this for many omnibus builds on a bunch of freebsd releases so it impacts us quite a bit. Would really appreciate it if it's possible. Thanks @tmatilai

tmatilai commented 10 years ago

The fix in master is part of a bigger change: 040e1a2e

But the fix should be trivial (also if you want to hot fix it locally). Just replace this line with (untested):

  :type => (@config.nfs ? :nfs : nil))
petecheslock commented 10 years ago

@tmatilai Absolutely brilliant! This workaround works for me. Thanks for unblocking me - really appreciate it.

petecheslock commented 10 years ago

As an FYI for others - I've added this to my Vagrant file so other people internally using this project don't run into the problem.

https://gist.github.com/petecheslock/b3bd7810f30336401fc7

Neetuj commented 10 years ago

@petecheslock @mitchellh i have vagrant version 1.6 and i still see the porblem. I am on windows. any pointers? ( I tried adding this to my vagrant file .. did not help)

==> default: Mounting shared folders... default: /vagrant => H:/office projects/interface_poller Vagrant attempted to execute the capability 'mount_virtualbox_shared_folder' on the detect guest OS 'freebsd', but the guest doesn't support that capability. This capability is required for your configuration of Vagrant. Please either reconfigure Vagrant to avoid this capability or fix the issue by creating the capability.

H:\office projects\interface_poller>vagrant version Installed Version: 1.6.3 Latest Version: 1.6.5

tmatilai commented 10 years ago

@Neetuj as far as I know, NFS is not supported on Windows hosts. You might want to try using samba or rsync.

Neetuj commented 10 years ago

will try thanks!