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 148 forks source link

Since upgrade to vagrant 2.0.1, my hostnames are assigned to 127.0.0.1 #250

Open tcataldo opened 6 years ago

tcataldo commented 6 years ago

The real ip (obtained from vmware dhcp) was assigned correctly with previous version. example VagrantFile:

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

# Ensure that VMWare Tools recompiles kernel modules
# when we update the linux images
$fix_vmware_tools_script = <<SCRIPT
mkdir -p /etc/vmware-tools
touch /etc/vmware-tools/locations
sed -i.bak 's/answer AUTO_KMODS_ENABLED_ANSWER no/answer AUTO_KMODS_ENABLED_ANSWER yes/g' /etc/vmware-tools/locations
sed -i 's/answer AUTO_KMODS_ENABLED no/answer AUTO_KMODS_ENABLED yes/g' /etc/vmware-tools/locations
SCRIPT

Vagrant.configure(2) do |config|
  config.vm.box = "tcataldo/ubuntu1604"

  config.vm.synced_folder ".", "/vagrant", type: "nfs"
  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.hostmanager.ignore_private_ip = false

  config.vm.provider "vmware_fusion" do |v|
    v.vmx["memsize"] = "512"
    v.vmx["numvcpus"] = "2"
    v.vmx["ethernet0.pcislotnumber"] = "33"
  end

  config.vm.define 'mapi' do |node|
    node.vm.hostname = 'mapi.ex2016.vmw'
    node.hostmanager.aliases = %w(autodiscover.ex2016.vmw)
    node.vm.provision "shell", inline: $fix_vmware_tools_script
    node.vm.provision "nginx", type: "shell", path: "nginx-ews.sh"
  end

end
punkrokk commented 6 years ago

I'm experiencing the same thing.

bdwyertech commented 6 years ago

This has to do with a behavior change in the VMware plugin itself... I noticed it a while back too.

https://github.com/hashicorp/vagrant/issues/9151

This is hack to keep it from getting in the way for now...

    config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
      if vm.id && vm.provider_name == :vmware_fusion
        `'/Applications/VMware Fusion.app/Contents/Library/vmrun' getGuestIPAddress "#{vm.id}" -wait`.chomp
      end
    end

Adding -wait to the vmrun command seems to have eliminated the issue on first boot.

punkrokk commented 6 years ago

@bdwyertech your solution works great for me. Thanks!

I may have gotten it working. More tomorrow.

Cheers,

JP

On Dec 18, 2017, at 5:14 PM, Brian Dwyer notifications@github.com wrote:

This has to do with a behavior change in the VMware plugin itself... I noticed it a while back too.

hashicorp/vagrant#9151

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Ilhicas commented 6 years ago

The same is happening to me with docker on version 2.0.2 , are you sure this is VMware related only issue? I could be messing something up.

Ilhicas commented 6 years ago

Just adding this issue is not only vmware related as I asked before and is vagrant version related https://github.com/devopsgroup-io/vagrant-hostmanager/issues/257

rgarrigue commented 6 years ago

I've the same issue if I enable dhcp instead of static IP

config.vm.network "private_network", type: "dhcp"

Tried playing with hostmanager options without success.

cdarlint commented 5 years ago

according to documentation as referenced in an official reply

setting v.ssh_info_public = true would solve the problem