From bc6c1afb1ece251d43d0915720110d9ee8e54ed7 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sat, 5 Nov 2016 15:22:28 +0100 Subject: [PATCH] Fix media_type detection on NetBSD On NetBSD 7.0.1, ifconfig return this: $ ifconfig ne0: flags=8863 mtu 1500 ec_capabilities=1 ec_enabled=0 address: 00:20:91:45:00:78 media: Ethernet 10baseT full-duplex inet 192.168.156.29 netmask 0xffffff00 broadcast 192.168.156.255 Which result into setup returning this: "media_type": "ull-duplex", So we have to specialise that method, since FreeBSD ifconfig return something like this: ue0: flags=8843 metric 0 mtu 1500 options=80009 ether 00:20:91:a7:48:45 inet 192.168.156.11 netmask 0xffffff00 broadcast 192.168.156.255 media: Ethernet autoselect (100baseTX ) status: active nd6 options=29 --- lib/ansible/module_utils/facts.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 211c337086..4275802980 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2953,6 +2953,22 @@ class NetBSDNetwork(GenericBsdIfconfigNetwork): """ platform = 'NetBSD' + def parse_media_line(self, words, current_if, ips): + # example of line: + # $ ifconfig + # ne0: flags=8863 mtu 1500 + # ec_capabilities=1 + # ec_enabled=0 + # address: 00:20:91:45:00:78 + # media: Ethernet 10baseT full-duplex + # inet 192.168.156.29 netmask 0xffffff00 broadcast 192.168.156.255 + current_if['media'] = words[1] + if len(words) > 2: + current_if['media_type'] = words[2] + if len(words) > 3: + current_if['media_options'] = words[3].split(',') + + class SunOSNetwork(GenericBsdIfconfigNetwork): """ This is the SunOS Network Class.