Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-2.10]: Fix AIX networks facts when nestat is either missing or has incorrect permissions #72713

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/72516-fix-aix-network-facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Fixed issue when `netstat` is either missing or doesn't have execution permissions leading to incorrect command being executed.
27 changes: 14 additions & 13 deletions lib/ansible/module_utils/facts/network/aix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down