devopsgroup-io / vagrant-hostmanager

:pencil: A Vagrant plugin that manages hosts files within a multi-machine environment.
Mozilla Public License 2.0
1.46k stars 146 forks source link

Support multiple NICs #224

Open drazenzubovic opened 7 years ago

drazenzubovic commented 7 years ago

Vagrant actually supports multiple adapters for a single VM, like two in this case:

Vagrant.configure("2") do |config|
  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.ignore_private_ip = false
  config.hostmanager.include_offline = true
  config.vm.define 'example-box' do |node|
    node.vm.hostname = 'example-box-hostname'

    node.vm.network "private_network", ip: '192.168.42.42'
    node.vm.network "private_network", ip: '10.0.0.42'

    node.hostmanager.aliases = %w(example-box.localdomain example-box-alias)
  end
end

Executing the script Vagrant will create and configure two private NICs. However hostmanager will only see and create entries in /etc/hosts for the first listed adapter.

It would be a good idea to extend the functionality and also support aliasing for multiple NICs with the hostmanager.