hashicorp / vagrant

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

private_network with auto_config false requires an ip with virtualbox but not vmware #7583

Open davidmnoriega opened 8 years ago

davidmnoriega commented 8 years ago

I primarily use VMware, so I had not noticed this before until a coworker using virtualbox had the problem. I use the following to add an additional nic, but not to do any configuration: node.vm.network "private_network", auto_config: false

This works fine with vmware, but with virtualbox, it throws an error because no ip is set. Re-reading the documentation, I see the example shows having an ip set along with auto_config: false, so the question is, which one is right?

Vagrant version

Currently using 1.8.4, same behavior with 1.8.1

Host operating system

Mac 10.11.5 VMware Fusion 8.1.1 VirtualBox 5.0.22

Guest operating system

bento/ubuntu-14.04

Vagrantfile

Vagrant.configure(2) do |config|
  config.ssh.insert_key = false
  config.vm.box = "bento/ubuntu-14.04"
  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true

  config.vm.define 'networking' do |node|
    config.vm.hostname = "networking.vagrant"
    node.vm.network "private_network", auto_config: false
    node.vm.network "private_network", auto_config: false
  end
end

Debug output

https://gist.github.com/davidmnoriega/c408a7ed5ecaf4d6f4ed89476c7a37bf

Expected behavior

I had expected the vagrant to come up just the same with virtualbox as I had with vmware

Actual behavior

$ vagrant up
Bringing machine 'networking' up with 'virtualbox' provider...
==> networking: Importing base box 'bento/ubuntu-14.04'...
==> networking: Matching MAC address for NAT networking...
==> networking: Checking if box 'bento/ubuntu-14.04' is up to date...
==> networking: Setting the name of the VM: networking_networking_1468513848376_25918
==> networking: Clearing any previously set network interfaces...
==> networking: Destroying VM and associated drives...
/opt/vagrant/embedded/lib/ruby/2.2.0/ipaddr.rb:475:in `initialize': address family must be specified (IPAddr::AddressFamilyError)

Steps to reproduce

  1. Add config.vm.network "private_network", auto_config: false to the vagrantfile
  2. vagrant up with virtualbox
  3. womp womp

    References

These issues contain the same exception, but with vmware and under slightly different circumstances, but maybe this is where the divergence between vmware and virtualbox comes from

davidmnoriega commented 6 years ago

I just ran into my own bug report today 😅

vStone commented 6 years ago
  # Default IP is in the 20-bit private network block for DHCP based networks
  options[:ip] = "172.28.128.1" if options[:type] == :dhcp || !options[:ip]

I changed the && to || here. Seems to work but in general it looks like the hostonly_config for virtualbox generally does not take auto_config into account.

larseggert commented 5 years ago

Issue still exists