Commit 1e4a2672 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed hyperleger inventory

parent 9197f050
...@@ -200,32 +200,34 @@ class AnsibleService: ...@@ -200,32 +200,34 @@ class AnsibleService:
children = {} children = {}
for vm in vms: for vm in vms:
attributes = vm.node_template.attributes attributes = vm.node_template.attributes
public_ip = attributes['public_ip']
vm_vars = {'ansible_host': public_ip}
vm_vars.update(vars)
roles = [] roles = []
if attributes['role'] == 'master': if attributes['role'] == 'master':
roles.append('swarm_manager_prime') roles.append('swarm_manager_prime')
roles.append('swarm_managers') roles.append('swarm_managers')
elif attributes['role'] == 'worker': elif attributes['role'] == 'worker':
roles.append('swarm_workers') roles.append('swarm_workers')
public_ip = attributes['public_ip'] fabric_count = 0
# vars['ansible_host'] = public_ip
for role in roles: for role in roles:
if role not in children: if role not in children:
hosts = {} hosts = {}
else: else:
hosts = children[role] hosts = children[role]
if 'hosts' in hosts: if 'hosts' in hosts:
# if role == 'swarm_manager_prime' or role == 'swarm_managers': if role == 'swarm_manager_prime' or role == 'swarm_managers':
# hosts['hosts'] = {'fabric-manager': vars} host = {'hlf' + str(fabric_count): vm_vars}
# else: else:
# hosts['hosts'] = {'fabric-worker': vars} fabric_count += 1
hosts['hosts'] = {public_ip: vars} host = {'hlf' + str(fabric_count): vm_vars}
hosts['hosts'] = host
else: else:
host = {} if role == 'swarm_manager_prime' or role == 'swarm_managers':
host[public_ip] = vars host = {'hlf' + str(fabric_count): vm_vars}
# if role == 'swarm_manager_prime' or role == 'swarm_managers': else:
# host = {'fabric-manager': vars} fabric_count += 1
# else: host = {'hlf' + str(fabric_count): vm_vars}
# host = {'fabric-worker': vars}
hosts['hosts'] = host hosts['hosts'] = host
children[role] = hosts children[role] = hosts
all['children'] = children all['children'] = children
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment