1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Try to find ip command in either /sbin or /usr/sbin

If ip is not found in either /sbin or /usr/sbin, this will return
an empty result.  It seems extremely unlikely that a linux system will
not have iproute2 installed
This commit is contained in:
Stephen Fromm 2012-08-11 12:05:08 -07:00
parent 84028c2339
commit c4ce5f9497

View file

@ -453,8 +453,13 @@ class LinuxNetwork(Network):
ipv4_address = None, ipv4_address = None,
ipv6_address = None ipv6_address = None
) )
ipbin = '/sbin/ip'
output = subprocess.Popen(['/sbin/ip','addr', 'show'], stdout=subprocess.PIPE).communicate()[0] if not os.path.exists(ipbin):
if os.path.exists('/usr/sbin/ip'):
ipbin = '/usr/sbin/ip'
else:
return interfaces, ips
output = subprocess.Popen([ipbin, 'addr', 'show'], stdout=subprocess.PIPE).communicate()[0]
for line in output.split('\n'): for line in output.split('\n'):
if line: if line:
words = line.split() words = line.split()