From e181bcf62bae83a02e041f4d5985fcd899ddcca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20S=C3=BCssemilch=20Poulain?= Date: Tue, 30 Sep 2014 20:50:01 +0200 Subject: [PATCH 1/3] Allows to fetch machine architecture as an unprivileged user --- lib/ansible/module_utils/facts.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index a3f8c05d65..cdc0faffa3 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -186,16 +186,21 @@ class Facts(object): if self.facts['system'] == 'Linux': self.get_distribution_facts() elif self.facts['system'] == 'AIX': - try: - rc, out, err = module.run_command("/usr/sbin/bootinfo -p") + # Attempt to use getconf to figure out architechture + # fall back to bootinfo if needed + if module.get_bin_path('getconf'): + rc, out, err = module.run_command([module.get_bin_path('getconf'), + 'MACHINE_ARCHITECTURE']) + data = out.split('\n') + self.facts['architecture'] = data[0] + else: + rc, out, err = module.run_command([module.get_bin_path('bootinfo'), + '-p']) data = out.split('\n') self.facts['architecture'] = data[0] - except: - self.facts['architecture'] = 'Not Available' elif self.facts['system'] == 'OpenBSD': self.facts['architecture'] = platform.uname()[5] - def get_local_facts(self): fact_path = module.params.get('fact_path', None) From 4614a574eadb0a245edae3bcf7acee1f84cd37b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20S=C3=BCssemilch=20Poulain?= Date: Tue, 30 Sep 2014 20:55:50 +0200 Subject: [PATCH 2/3] Allows network network interface facts collection as an unprivileged user and adds more facts --- lib/ansible/module_utils/facts.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index cdc0faffa3..0aa7fbf9a7 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2278,6 +2278,26 @@ class AIXNetwork(GenericBsdIfconfigNetwork, Network): """ platform = 'AIX' + def get_default_interfaces(self, route_path): + netstat_path = module.get_bin_path('netstat') + + rc, out, err = module.run_command([netstat_path, '-nr']) + + interface = dict(v4 = {}, v6 = {}) + + lines = out.split('\n') + 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'] + # AIX 'ifconfig -a' does not have three words in the interface line def get_interfaces_info(self, ifconfig_path, ifconfig_options): interfaces = {} From 02294c52ceefff4bbffe68b0bb5afbfe6916739e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20S=C3=BCssemilch=20Poulain?= Date: Fri, 31 Jul 2015 13:25:42 +0200 Subject: [PATCH 3/3] Typo --- lib/ansible/module_utils/facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 0aa7fbf9a7..b2930818c2 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -186,7 +186,7 @@ class Facts(object): if self.facts['system'] == 'Linux': self.get_distribution_facts() elif self.facts['system'] == 'AIX': - # Attempt to use getconf to figure out architechture + # Attempt to use getconf to figure out architecture # fall back to bootinfo if needed if module.get_bin_path('getconf'): rc, out, err = module.run_command([module.get_bin_path('getconf'),