From 250620f2abfcdbdd1be0d963969dac8d2a8c7521 Mon Sep 17 00:00:00 2001 From: Trapier Marshall Date: Wed, 17 Dec 2014 14:27:18 -0500 Subject: [PATCH] Add pciid to LinuxNetwork interface fact This commit adds pciid to the LinuxNetwork fact object. pciid is gathered if the symlink /sys/class/net/*/device exists. Example [>>>> emphasis <<<<]: $ readlink /sys/class/net/eth0/device ../../../0000:01:00.0 $ ansible localhost --ask-pass -i /tmp/hosts -m setup -a "filter=ansible_eth0" SSH password: localhost | success >> { "ansible_facts": { "ansible_eth0": { "active": false, "device": "eth0", "macaddress": "0c:d2:92:5d:6e:8e", "module": "alx", "mtu": 1500, >>>> "pciid": "0000:01:00.0", <<<< "promisc": true, "type": "ether" } }, "changed": false } --- lib/ansible/module_utils/facts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 855a470a083..cc070d27042 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1858,6 +1858,8 @@ class LinuxNetwork(Network): path = os.path.join(path, 'bonding', 'all_slaves_active') if os.path.exists(path): interfaces[device]['all_slaves_active'] = get_file_content(path) == '1' + if os.path.exists(os.path.join(path,'device')): + interfaces[device]['pciid'] = os.path.basename(os.readlink(os.path.join(path,'device'))) # Check whether an interface is in promiscuous mode if os.path.exists(os.path.join(path,'flags')):