puppetlabs / facter

Collect and display system facts
https://puppet.com/open-source/#osp
Apache License 2.0
621 stars 497 forks source link

Can't access fact that contains `.` in key #2750

Open morsik opened 2 months ago

morsik commented 2 months ago

Describe the Bug

Can't access fact that contains . in key

Expected Behavior

Data should be replied correctly, because network interface names contains dots when used VLANs.

Steps to Reproduce

Try to access IP from VLAN interface because those contain dot.

root@host ~ # facter networking.interfaces.ens1f0.ip
213.X.Y.Z
root@host ~ # facter networking.interfaces.ens1f0.4001.ip

root@host ~ # facter networking.interfaces."ens1f0.4001".ip

root@host ~ # facter 'networking.interfaces."ens1f0.4001".ip'

root@host ~ #

But this data actually exists!

# facter networking.interfaces
{
  eno8303 => {
    mac => "c4:cb:e1:XX:YY:ZZ",
    mtu => 1500
  },
  eno8403 => {
    mac => "c4:cb:e1:XX:YY:ZZ",
    mtu => 1500
  },
  ens1f0 => {
    bindings => [
      {
        address => "213.X.Y.Z",
        netmask => "255.255.255.128",
        network => "213.X.Y.Z"
      }
    ],
    ip => "213.X.Y.Z",
    mac => "6c:fe:54:XX:YY:ZZ",
    mtu => 1500,
    netmask => "255.255.255.128",
    network => "213.X.Y.Z"
  },
  ens1f0.4001 => {
    bindings => [
      {
        address => "10.X.Y.Z",
        netmask => "255.255.0.0",
        network => "10.X.Y.Z"
      }
    ],
    ip => "10.X.Y.Z",
    mac => "6c:fe:54:XX:YY:ZZ"
    mtu => 1400,
    netmask => "255.255.0.0",
    network => "10.X.Y.Z"
  },
  ens1f1 => {
    mac => "6c:fe:54:XX:YY:ZZ",
    mtu => 1500
  },
  lo => {
    bindings => [
      {
        address => "127.0.0.1",
        netmask => "255.0.0.0",
        network => "127.0.0.0"
      }
    ],
    ip => "127.0.0.1",
    mtu => 65536,
    netmask => "255.0.0.0",
    network => "127.0.0.0"
  }
}

Environment

joshcooper commented 2 months ago

Yes, facter 4 has some bugs with dotted notation. The main problem is it naively splits on dots. I have a feature branch here but it needs more work: https://github.com/puppetlabs/facter/compare/main...joshcooper:dots_3447