read ip from eth1 if using host-only network
If the the vms are using host-only network, then eth1 would be the proper interface to retrieve ip of the vm. Without these lines, the host manager will only add 127.0.0.1 to /etc/hosts file. Change-Id: If2f825ebb9d6f7f096ce55e1bf070e5af91f5d45
This commit is contained in:
parent
1782ba1a5b
commit
eab558e288
|
@ -126,6 +126,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
config.hostmanager.manage_host = true
|
||||
config.hostmanager.ignore_private_ip = false
|
||||
config.hostmanager.include_offline = true
|
||||
if conf["use_bridge"] == false
|
||||
config.hostmanager.ip_resolver = proc do |machine|
|
||||
result = ""
|
||||
machine.communicate.execute("ifconfig eth1") do |type, data|
|
||||
result << data if type == :stdout
|
||||
end
|
||||
(ip = /inet addr:(\d+\.\d+\.\d+\.\d+)/.match(result)) && ip[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.define "manager", primary: true do |manager|
|
||||
|
|
Loading…
Reference in New Issue