diff options
author | Egor Margineanu <egmar@users.noreply.github.com> | 2020-11-10 16:07:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 10:07:28 -0500 |
commit | e879f12fb9629842f6c9c1a18ebd9dfd3e23de32 (patch) | |
tree | eb123ec9bd2d96a3977e34a9a0e4f09d11af62c6 /lib/ansible | |
parent | d451433e5d96c9f2f8cbe30c316c128ff591edf1 (diff) | |
download | ansible-e879f12fb9629842f6c9c1a18ebd9dfd3e23de32.tar.gz |
Fix AIX networks facts when nestat is either missing or has incorrect permissions (#72516)
* Added check for none on netstat_path variable
* Added changelog
Diffstat (limited to 'lib/ansible')
-rw-r--r-- | lib/ansible/module_utils/facts/network/aix.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/ansible/module_utils/facts/network/aix.py b/lib/ansible/module_utils/facts/network/aix.py index 46bbb68f67..e9c90c6413 100644 --- a/lib/ansible/module_utils/facts/network/aix.py +++ b/lib/ansible/module_utils/facts/network/aix.py @@ -30,22 +30,23 @@ class AIXNetwork(GenericBsdIfconfigNetwork): platform = 'AIX' def get_default_interfaces(self, route_path): + interface = dict(v4={}, v6={}) + netstat_path = self.module.get_bin_path('netstat') - rc, out, err = self.module.run_command([netstat_path, '-nr']) + if netstat_path: + rc, out, err = self.module.run_command([netstat_path, '-nr']) - interface = dict(v4={}, v6={}) - - lines = out.splitlines() - for line in lines: - words = line.split() - if len(words) > 1 and words[0] == 'default': - if '.' in words[1]: - interface['v4']['gateway'] = words[1] - interface['v4']['interface'] = words[5] - elif ':' in words[1]: - interface['v6']['gateway'] = words[1] - interface['v6']['interface'] = words[5] + lines = out.splitlines() + for line in lines: + words = line.split() + if len(words) > 1 and words[0] == 'default': + if '.' in words[1]: + interface['v4']['gateway'] = words[1] + interface['v4']['interface'] = words[5] + elif ':' in words[1]: + interface['v6']['gateway'] = words[1] + interface['v6']['interface'] = words[5] return interface['v4'], interface['v6'] |