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

* facts: detect IP addresses on busybox properly

Fixes #50871

* Check rc before parsing data

* Ooops
This commit is contained in:
Martin Krizek 2019-01-23 22:24:29 +01:00 committed by GitHub
parent 16511501b6
commit 11fb0a5d6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

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

View file

@ -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))