1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allows to fetch machine architecture as an unprivileged user

This commit is contained in:
Jonathan Süssemilch Poulain 2014-09-30 20:50:01 +02:00 committed by Jonathan Süssemilch Poulain
parent 9aa4214417
commit e181bcf62b

View file

@ -186,16 +186,21 @@ class Facts(object):
if self.facts['system'] == 'Linux': if self.facts['system'] == 'Linux':
self.get_distribution_facts() self.get_distribution_facts()
elif self.facts['system'] == 'AIX': elif self.facts['system'] == 'AIX':
try: # Attempt to use getconf to figure out architechture
rc, out, err = module.run_command("/usr/sbin/bootinfo -p") # 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') data = out.split('\n')
self.facts['architecture'] = data[0] self.facts['architecture'] = data[0]
except:
self.facts['architecture'] = 'Not Available'
elif self.facts['system'] == 'OpenBSD': elif self.facts['system'] == 'OpenBSD':
self.facts['architecture'] = platform.uname()[5] self.facts['architecture'] = platform.uname()[5]
def get_local_facts(self): def get_local_facts(self):
fact_path = module.params.get('fact_path', None) fact_path = module.params.get('fact_path', None)