facts: detect IP addresses on busybox properly (#51131)

* facts: detect IP addresses on busybox properly

Fixes #50871

* Check rc before parsing data

* Ooops
pull/51247/merge
Martin Krizek 6 years ago committed by GitHub
parent 16511501b6
commit 11fb0a5d6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Detect IP addresses on a system with busybox properly (https://github.com/ansible/ansible/issues/50871)

@ -256,12 +256,20 @@ class LinuxNetwork(Network):
args = [ip_path, 'addr', 'show', 'primary', device]
rc, primary_data, stderr = self.module.run_command(args, errors='surrogate_then_replace')
if rc == 0:
parse_ip_output(primary_data)
else:
# possibly busybox, fallback to running without the "primary" arg
# https://github.com/ansible/ansible/issues/50871
args = [ip_path, 'addr', 'show', device]
rc, data, stderr = self.module.run_command(args, errors='surrogate_then_replace')
if rc == 0:
parse_ip_output(data)
args = [ip_path, 'addr', 'show', 'secondary', device]
rc, secondary_data, stderr = self.module.run_command(args, errors='surrogate_then_replace')
parse_ip_output(primary_data)
parse_ip_output(secondary_data, secondary=True)
if rc == 0:
parse_ip_output(secondary_data, secondary=True)
interfaces[device].update(self.get_ethtool_data(device))

Loading…
Cancel
Save