mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Bug Fix
-Corrected the format in case of multiple hosts Remove empty spaces
This commit is contained in:
parent
2984ffdfac
commit
d180e0e05f
1 changed files with 6 additions and 4 deletions
|
@ -13,8 +13,10 @@ class RackhdInventory(object):
|
||||||
self._inventory = {}
|
self._inventory = {}
|
||||||
for nodeid in nodeids:
|
for nodeid in nodeids:
|
||||||
self._load_inventory_data(nodeid)
|
self._load_inventory_data(nodeid)
|
||||||
|
inventory = {}
|
||||||
for nodeid,info in self._inventory.iteritems():
|
for nodeid,info in self._inventory.iteritems():
|
||||||
print(json.dumps(self._format_output(nodeid, info)))
|
inventory[nodeid]= (self._format_output(nodeid, info))
|
||||||
|
print(json.dumps(inventory))
|
||||||
|
|
||||||
def _load_inventory_data(self, nodeid):
|
def _load_inventory_data(self, nodeid):
|
||||||
info = {}
|
info = {}
|
||||||
|
@ -33,10 +35,10 @@ class RackhdInventory(object):
|
||||||
ipaddress = ''
|
ipaddress = ''
|
||||||
if len(node_info) > 0:
|
if len(node_info) > 0:
|
||||||
ipaddress = node_info[0]['ipAddress']
|
ipaddress = node_info[0]['ipAddress']
|
||||||
output = {nodeid:{ 'hosts':[ipaddress],'vars':{}}}
|
output = { 'hosts':[ipaddress],'vars':{}}
|
||||||
for key,result in info.iteritems():
|
for key,result in info.iteritems():
|
||||||
output[nodeid]['vars'][key] = json.loads(result)
|
output['vars'][key] = json.loads(result)
|
||||||
output[nodeid]['vars']['ansible_ssh_user'] = 'monorail'
|
output['vars']['ansible_ssh_user'] = 'monorail'
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return output
|
return output
|
||||||
|
|
Loading…
Reference in a new issue