Primary interface detection does not work

So the issue 26727 fixes situation when there’s just a bond as a primary interface, for example:

  "macaddress": "3c:fd:fe:cd:77:a0",
  "macaddress_bond0": "3c:fd:fe:cd:77:a0",
  "macaddress_em1": "e4:43:4b:47:b4:50",
  "macaddress_em2": "e4:43:4b:47:b4:51",
  "macaddress_em3": "e4:43:4b:47:b4:52",
  "macaddress_em4": "e4:43:4b:47:b4:53",
  "macaddress_p5p1": "3c:fd:fe:cd:77:a0",
  "macaddress_p5p2": "3c:fd:fe:cd:77:a1",
  "macaddress_p7p1": "b4:96:91:40:9d:08",
  "macaddress_p7p2": "b4:96:91:40:9d:0a",

However in your case I see you have a bond and VLAN on top of that:

  "macaddress": "1c:b7:2c:0a:34:39",
  "macaddress_backend": "b4:96:91:00:5a:58",
  "macaddress_bond0": "1c:b7:2c:0a:34:39",
  "macaddress_bond1": "b4:96:91:00:5a:58",
  "macaddress_enp130s0f0": "b4:96:91:00:5a:58",
  "macaddress_enp130s0f1": "b4:96:91:00:5a:5a",
  "macaddress_enp3s0f0": "1c:b7:2c:0a:34:39",
  "macaddress_enp3s0f1": "1c:b7:2c:0a:34:3a",
  "macaddress_pe_customer_net": "1c:b7:2c:0a:34:39",
  "macaddress_vlan106": "1c:b7:2c:0a:34:39",

This is tricky, facter reports MAC 1c:b7:2c:0a:34:39 as the primary interface which are actually multiple interfaces:

  • enp3s0f0
  • bond0
  • pe_customer_net
  • vlan106

Which one of these should be considered the primary one? I think it’s a problem and the limitation here is how facter reports this - just a MAC address is probably not enough to detect this complex scenario.

The answer probably lies in the facter 3.x (modern) facts which we don’t parse at the moment, just few basic things. It does contain key called “primary” which is set to “pe_customer_net” which I guess identifies your primary interface you want to be detected. However this is bunch of work - we need to refactor/rewrite our fact importing code, I am not sure when this is gonna happen.

The relevant bit is:

  "networking": {
    "domain": "ad1.myDomain.com",
    "fqdn": "claas-pro-pg-n1.ad1.myDomain.com",
    "hostname": "claas-pro-pg-n1",
    "interfaces": {
      "backend": {
        "bindings": [
          {
            "address": "192.168.142.45",
            "netmask": "255.255.255.0",
            "network": "192.168.142.0"
          }
        ],
        "bindings6": [
          {
            "address": "fe80::49b:baff:fe99:d0db",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network": "fe80::"
          }
        ],
        "ip": "192.168.142.45",
        "ip6": "fe80::49b:baff:fe99:d0db",
        "mac": "b4:96:91:00:5a:58",
        "mtu": 1500,
        "netmask": "255.255.255.0",
        "netmask6": "ffff:ffff:ffff:ffff::",
        "network": "192.168.142.0",
        "network6": "fe80::"
      },
      "bond0": {
        "bindings6": [
          {
            "address": "fe80::1eb7:2cff:fe0a:3439",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network": "fe80::"
          }
        ],
        "ip6": "fe80::1eb7:2cff:fe0a:3439",
        "mac": "1c:b7:2c:0a:34:39",
        "mtu": 1500,
        "netmask6": "ffff:ffff:ffff:ffff::",
        "network6": "fe80::"
      },
      "bond1": {
        "bindings6": [
          {
            "address": "fe80::b696:91ff:fe00:5a58",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network": "fe80::"
          }
        ],
        "ip6": "fe80::b696:91ff:fe00:5a58",
        "mac": "b4:96:91:00:5a:58",
        "mtu": 1500,
        "netmask6": "ffff:ffff:ffff:ffff::",
        "network6": "fe80::"
      },
      "enp130s0f0": {
        "mac": "b4:96:91:00:5a:58",
        "mtu": 1500
      },
      "enp130s0f1": {
        "mac": "b4:96:91:00:5a:5a",
        "mtu": 1500
      },
      "enp3s0f0": {
        "mac": "1c:b7:2c:0a:34:39",
        "mtu": 1500
      },
      "enp3s0f1": {
        "mac": "1c:b7:2c:0a:34:3a",
        "mtu": 1500
      },
      "lo": {
        "bindings": [
          {
            "address": "127.0.0.1",
            "netmask": "255.0.0.0",
            "network": "127.0.0.0"
          }
        ],
        "bindings6": [
          {
            "address": "::1",
            "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
            "network": "::1"
          }
        ],
        "ip": "127.0.0.1",
        "ip6": "::1",
        "mtu": 65536,
        "netmask": "255.0.0.0",
        "netmask6": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
        "network": "127.0.0.0",
        "network6": "::1"
      },
      "pe_customer_net": {
        "bindings": [
          {
            "address": "10.10.6.45",
            "netmask": "255.255.255.0",
            "network": "10.10.6.0"
          }
        ],
        "bindings6": [
          {
            "address": "fe80::1eb7:2cff:fe0a:3439",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network": "fe80::"
          }
        ],
        "ip": "10.10.6.45",
        "ip6": "fe80::1eb7:2cff:fe0a:3439",
        "mac": "1c:b7:2c:0a:34:39",
        "mtu": 1500,
        "netmask": "255.255.255.0",
        "netmask6": "ffff:ffff:ffff:ffff::",
        "network": "10.10.6.0",
        "network6": "fe80::"
      },
      "vlan106": {
        "bindings6": [
          {
            "address": "fe80::1eb7:2cff:fe0a:3439",
            "netmask": "ffff:ffff:ffff:ffff::",
            "network": "fe80::"
          }
        ],
        "ip6": "fe80::1eb7:2cff:fe0a:3439",
        "mac": "1c:b7:2c:0a:34:39",
        "mtu": 1500,
        "netmask6": "ffff:ffff:ffff:ffff::",
        "network6": "fe80::"
      }
    },
    "ip": "10.10.6.45",
    "ip6": "fe80::1eb7:2cff:fe0a:3439",
    "mac": "1c:b7:2c:0a:34:39",
    "mtu": 1500,
    "netmask": "255.255.255.0",
    "netmask6": "ffff:ffff:ffff:ffff::",
    "network": "10.10.6.0",
    "network6": "fe80::",
    "primary": "pe_customer_net"
  },

Out of curiosity, can you describe your NIC setup? Those four layers.

  • 2 physical NICs
  • those 2 for redundancy combined to a bond
  • on top of the bond multiple VLANs
  • for Proxmox hypervisor a vmbridge to the the VLAN is required

Makes sense.

Here is a patch that should help:

However the situation is not great. You are lucky that your bridge is not named “bridgeX” or “br-X” because then our heuristic code which aims to pick the “best” primary interface would prefer the VLAN interface. Even facter3 networking facts are not detailed enough for Foreman to understand how things are set up.

Even if I try to set an IP manually, the UI often brings errors related to all those NICs and if I delete them and set the correct NIC/IP, it will be resetted after the next puppet agent run :frowning:
Is there a workaround?

Well you can disable updating NICs from puppet in Administer - Settings but that’s pretty much it.

But that is a general setting, right?
From 350 hosts maybe 10 are problematic…

It’s bummer but our NIC parsing code does lot of “heuristic” and it can’t do much as there is not enough information.

To make a long story short: In my case the best solution was to use the fact networking::primary to identify the primary interface and use the fact networking::interfaces::$NETWORKING::PRIMARY_VALUE::ip' to get the IP.