Search code examples
vagrantpuppetvagrantfile

Vagrant - 2 VMs have same IP


Im trying to play around with puppet. So I fired up two debian instances using vagrant. My Vagrantfile looks like this

Vagrant.configure("2") do |config|

  config.vm.define "puppetagent" do |puppetagent|
    puppetagent.vm.box = "puphpet/debian75-x64"
    puppetagent.vm.hostname = "puppetagent.example.com"
    puppetagent.vm.network "private_network",ip: "192.168.10.21"
  end

  config.vm.define "puppetmaster" do |puppetmaster|
    puppetmaster.vm.box = "puphpet/debian75-x64"
    puppetmaster.vm.hostname = "puppetmaster.example.com"
    puppetmaster.vm.network "private_network",ip: "192.168.10.22"
  end

However when I ssh into both the instances, and look into /etc/hosts the files (on both ) look like this:

# master - instance1

127.0.0.1   localhost
127.0.1.1 puppetmaster.example.com puppetmaster

# agent - instance2

127.0.0.1   localhost
127.0.1.1 puppetagent.example.com puppetagent

Im confused regarding this. I did specify diff IP's for both, but why does it show same IP's in the hosts file?


Solution

  • Could I hazard a guess that you are running a debian based VM?

    The 127.0.1.1 line, although not a debian specifity per se is added by the debian installer as is explained on the debian manual. Not all Unices do so.

    This is loopback addres, nothing to do with the actual IP adress from your VM, regardless if you are using debian or not.

    If you want to have /etc/hosts updated by vagrant, you will need to use a plugin like Vagrant hostmanager.