ansible-role-interfaces icon indicating copy to clipboard operation
ansible-role-interfaces copied to clipboard

error when changing default gateway to another interface

Open pescobar opened this issue 5 years ago • 3 comments

I am trying to configure a machine that is working with gateway 10.10.10.1 (eth0) to use a different gateway (100.100.100.254) in eth1 . this is my config:

interfaces_ether_interfaces:
  - device: eth0
    bootproto: dhcp
    dnsnameservers: 10.10.10.1
  - device: eth1
    bootproto: static
    address: 100.100.100.66
    netmask: 255.255.255.0
    gateway: 100.100.100.254

When I run the role I get this error:

RUNNING HANDLER [MichaelRigart.interfaces : Check active Ethernet interface state] ****************************************************************************************************************************************************
skipping: [sosci-devel.scicore-dmz.lan] => (item={u'device': u'eth0', u'dnsnameservers': u'10.10.10.1', u'bootproto': u'dhcp', u'dnssearch': u'scicore-dmz.lan scicore.unibas.ch unibas.ch'})  => {
    "changed": false,
    "item": {
        "bootproto": "dhcp",
        "device": "eth0",
        "dnsnameservers": "10.10.10.1",
       },
    "skip_reason": "Conditional result was False"
}
failed: [sosci-devel.scicore-dmz.lan] (item={u'device': u'eth1', u'netmask': u'255.255.255.0', u'bootproto': u'static', u'gateway': u'100.100.100.254', u'address': u'100.100.100.66'}) => {
    "changed": false,
    "item": {
        "address": "100.100.100.66",
        "bootproto": "static",
        "device": "eth1",
        "gateway": "100.100.100.254",
        "netmask": "255.255.255.0"
    },
    "msg": "Default IPv4 gateway is incorrect"
}

If I rerun the role it works fine at the second try.

I could also workaround the issue by commenting out these lines

any suggestion about how to do a proper fix that could be merged upstream? I can test it and send a PR

pescobar avatar Jun 18 '19 11:06 pescobar

Hi Pablo, can you check what the default route is after the first and second runs? Has the network config been applied successfully or not?

markgoddard avatar Jun 18 '19 13:06 markgoddard

ups, I missed this...sorry for the late reply. I will do the requested tests tomorrow and I will reply here again

pescobar avatar Jun 23 '19 20:06 pescobar

this is the network config with a clean installation of the machine (no ansible execution yet)

$> ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 3e:ae:97:38:7d:c9 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.17/25 brd 10.10.10.127 scope global noprefixroute dynamic eth0
       valid_lft 42695sec preferred_lft 42695sec
    inet6 fe80::3cae:97ff:fe38:7dc9/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 06:a5:b3:8f:34:fd brd ff:ff:ff:ff:ff:ff
$> ip r
default via 10.10.10.1 dev eth0 proto dhcp metric 100
10.10.10.0/25 dev eth0 proto kernel scope link src 10.10.10.17 metric 100

after the first run I get the error in RUNNING HANDLER [MichaelRigart.interfaces : Check active Ethernet interface state] and this the network status after the error:

$> ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 3e:ae:97:38:7d:c9 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.17/25 brd 10.10.10.127 scope global dynamic eth0
       valid_lft 43120sec preferred_lft 43120sec
    inet6 fe80::3cae:97ff:fe38:7dc9/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 06:a5:b3:8f:34:fd brd ff:ff:ff:ff:ff:ff
    inet 100.100.100.66/24 brd 100.100.100.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::4a5:b3ff:fe8f:34fd/64 scope link
       valid_lft forever preferred_lft forever
$> ip r
default via 10.10.10.1 dev eth0
10.10.10.0/25 dev eth0 proto kernel scope link src 10.10.10.17
100.100.100.0/24 dev eth1 proto kernel scope link src 100.100.100.66
169.254.0.0/16 dev eth0 scope link metric 1002
169.254.0.0/16 dev eth1 scope link metric 1003

and after second execution it works fine and this is the final network status:

$> ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 3e:ae:97:38:7d:c9 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.17/25 brd 10.10.10.127 scope global dynamic eth0
       valid_lft 42953sec preferred_lft 42953sec
    inet6 fe80::3cae:97ff:fe38:7dc9/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 06:a5:b3:8f:34:fd brd ff:ff:ff:ff:ff:ff
    inet 100.100.100.66/24 brd 100.100.100.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::4a5:b3ff:fe8f:34fd/64 scope link
       valid_lft forever preferred_lft forever
$> ip r
default via 100.100.100.254 dev eth1
10.10.10.0/25 dev eth0 proto kernel scope link src 10.10.10.17
100.100.100.0/24 dev eth1 proto kernel scope link src 100.100.100.66
169.254.0.0/16 dev eth0 scope link metric 1002
169.254.0.0/16 dev eth1 scope link metric 1003

thanks for looking into this issue

pescobar avatar Jun 24 '19 14:06 pescobar