chef / ohai

Ohai profiles your system and emits JSON
https://docs.chef.io/ohai.html
Apache License 2.0
681 stars 452 forks source link

node['ipaddress'] unpopulated on Solaris when hosting zones #512

Closed curiositycasualty closed 8 years ago

curiositycasualty commented 9 years ago

The regex used to collect this attribute doesn't seem to handle the : syntax if zones are present on the system.

Some example output of ifconfig -a from Solaris 11 and Solaris 10 respectively.

#ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone kitchen-8b118c81f9ce
        inet 127.0.0.1 netmask ff000000
net0: flags=100001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,PHYSRUNNING> mtu 1500 index 2
        inet 172.31.8.25 netmask fffffc00 broadcast 172.31.11.255
        ether 0:21:28:26:dc:38
net0:1: flags=100001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,PHYSRUNNING> mtu 1500 index 2
        zone kitchen-8b118c81f9ce
        inet 172.31.9.61 netmask fffffc00 broadcast 172.31.11.255
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
        inet6 ::1/128
lo0:1: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
        zone kitchen-8b118c81f9ce
        inet6 ::1/128
net0: flags=120002004841<UP,RUNNING,MULTICAST,DHCP,IPv6,PHYSRUNNING> mtu 1500 index 2
        inet6 fe80::221:28ff:fe26:dc38/10
        ether 0:21:28:26:dc:38
#ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone angry-bees-scott
        inet 127.0.0.1 netmask ff000000
lo0:2: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone angrychef-solaris-10-i86pc-builder-1c4694
        inet 127.0.0.1 netmask ff000000
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone angrychef-solaris-10-i86pc-tester-27cb77
        inet 127.0.0.1 netmask ff000000
lo0:4: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        zone kitchen-5eb5f1a8367d
        inet 127.0.0.1 netmask ff000000
bnx0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 172.31.8.23 netmask fffffc00 broadcast 172.31.11.255
        ether b8:ac:6f:12:17:be
bnx0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone angry-bees-scott
        inet 172.31.9.28 netmask fffffc00 broadcast 172.31.11.255
bnx0:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone angrychef-solaris-10-i86pc-builder-1c4694
        inet 172.31.9.27 netmask fffffc00 broadcast 172.31.11.255
bnx0:3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone angrychef-solaris-10-i86pc-tester-27cb77
        inet 172.31.9.26 netmask fffffc00 broadcast 172.31.11.255
bnx0:4: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone kitchen-5eb5f1a8367d
        inet 172.31.9.37 netmask fffffc00 broadcast 172.31.11.255
schisamo commented 9 years ago

I'm seeing the same thing when running Ohai in a zone also:

root@angrychef-solaris-11-i86pc-builder-c756e7:~# ifconfig -a
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
net0:3: flags=100001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,PHYSRUNNING> mtu 1500 index 2
        inet 172.31.9.75 netmask fffffc00 broadcast 172.31.11.255
lo0:3: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
        inet6 ::1/128
lamont-granquist commented 8 years ago

did we ever fix this?

curiositycasualty commented 8 years ago

@lamont-granquist yep:

0 root@virtsol02:/#ohai ipaddress
[
  "172.31.8.23"
]
0 root@virtsol02:/#ohai network
<snip>
    "bnx0:2": {
      "mtu": "1500",
      "index": "2",
      "flags": [
        "UP",
        "BROADCAST",
        "RUNNING",
        "MULTICAST",
        "IPv4"
      ],
      "type": "bnx",
      "number": "0:2",
      "encapsulation": "Unknown",
      "addresses": {
        "172.31.9.27": {
          "family": "inet",
          "netmask": "255.255.252.0",
          "broadcast": "172.31.11.255"
        }
      }
    },
<snip>