2

I can't defeat Vagrant/VirtualBox and Ansible, please help. Here is my network conf for in Vagrant:

 config.vm.define "mesosnode01" do |node1|
    node1.vm.box = "ubuntu/trusty64"
    node1.vm.hostname = "mesosnode01"
    node1.vm.network  "private_network", ip: "192.168.56.10"
    config.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--memory", "3072"]
    end
  end

I expect that default eth device would have 192.168.56.10 address. But I'm wrong. Here is output:

for ip route list:

vagrant@mesosnode01:~$ sudo ip route list
default via 10.0.2.2 dev eth0 
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15 
192.168.56.0/24 dev eth1  proto kernel  scope link  src 192.168.56.10 

for ifconfig on VM side:

vagrant@mesosnode01:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:84:06:a3  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe84:6a3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1922 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1247 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:191345 (191.3 KB)  TX bytes:163962 (163.9 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:fc:bb:de  
          inet addr:192.168.56.10  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fefc:bbde/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:132 errors:0 dropped:0 overruns:0 frame:0
          TX packets:91 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:109552 (109.5 KB)  TX bytes:23202 (23.2 KB)

So part of my services start on 10.0.2.15, the other part starts on expected 192.168.56.10.

The problem is that my Ansible roles (taken from galaxy/github) use ansible_default_ipv4 and it points to "wrong" interface.

"ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "10.0.2.15", 
            "192.168.56.10"
        ], 
"ansible_default_ipv4": {
            "address": "10.0.2.15", 
            "alias": "eth0", 
            "gateway": "10.0.2.2", 
            "interface": "eth0", 
            "macaddress": "08:00:27:84:06:a3", 
            "mtu": 1500, 
            "netmask": "255.255.255.0", 
            "network": "10.0.2.0", 
            "type": "ether"
        }, 

What do I do wrong?

1 Answer 1

-1

please have a look at @techraf answer. I've created a task using info from that answer:

- name: set eth1 to default interface
  shell: route add -net 8.8.8.8 netmask 255.255.255.255 eth1
  when : ansible_default_ipv4.alias != "eth1"

This command idempotent, you can run it as many times as you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .