Fix AIX networks facts when nestat is either missing or has incorrect permissions (#72516)

* Added check for none on netstat_path variable

* Added changelog
pull/60081/merge
Egor Margineanu 4 years ago committed by GitHub
parent d451433e5d
commit e879f12fb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fixed issue when `netstat` is either missing or doesn't have execution permissions leading to incorrect command being executed.

@ -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']

Loading…
Cancel
Save