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