mitchellh/vagrant — Issue #524: guest_ip function broken when not using second nic
Author: hh
Created: 2011-10-14 00:39:49+00:00
State: open

```cucumber
As a DevOp
I want to create a Vagrantbox with an NFS mount
In order to share the chef-file-cache

When I have a Vagrantbox with one nic setup for NAT
And I have config.nfs = true
Then vagrant shouldn't look for a second nic configured for
```

For some reason nfs.rb points to the second nic, and assumes it to be host-only.
Is that by design?
Should this work with a NAT or other interface?

https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/action/vm/nfs.rb#L138

```ruby
# Returns the IP address of the guest by looking at the first
# enabled host only network.
#
# @return [String]
def guest_ip
@env["config"].vm.network_options[1][:ip]
end
```

Which breaks if I do something like:

```ruby
chef_config.vm.provision :chef_solo do |chef|
chef.nfs = true # seems to break things
#chef.data_bags_path = "data_bags" # mounts first, before anything else
chef.provisioning_path = "/vagrant" # by default where the cache is... I want it shared, mounts second
chef.cookbooks_path = "cookbooks", "site-cookbooks" # mounts third and fourth
```

with

```
vagrant destroy ; vagrant up
[chef] Forcing shutdown of VM...
[chef] Destroying VM and associated drives...
[chef] Importing base box 'vv17'...
[chef] Exporting NFS shared folders...
[chef] Destroying VM and associated drives...
/usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/nfs.rb:139:in `guest_ip': undefined method `[]' for
nil:NilClass (NoMethodError)
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/nfs.rb:109:in `export_folders'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/nfs.rb:36:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/provision.rb:17:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/forward_ports.rb:92:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/clear_forwarded_ports.rb:21:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/clean_machine_folder.rb:17:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/check_guest_additions.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/match_mac_address.rb:21:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/import.rb:26:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/vm/check_box.rb:23:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/warden.rb:30:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action/builder.rb:120:in `call'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action.rb:134:in `run'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/util/busy.rb:19:in `busy'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action.rb:134:in `run'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/environment.rb:364:in `lock'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/environment.rb:354:in `open'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/environment.rb:354:in `lock'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/action.rb:133:in `run'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/vm.rb:140:in `up'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/command/up.rb:13:in `execute'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/command/up.rb:8:in `each'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/command/up.rb:8:in `execute'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/task.rb:22:in `send'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/config.rb:115:in `map'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/core_ext/ordered_hash.rb:73:in `each'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `send'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/lib/vagrant/cli.rb:45:in `up'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/task.rb:22:in `send'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/gems/vagrant-0.8.6/bin/vagrant:21
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/bin/vagrant:19:in `load'
from /usr/local/rvm/gems/ree-1.8.7-2011.03@boot/bin/vagrant:19
```