Commit 28dfc109 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed hyperleger inventory

parent 1e4a2672
...@@ -64,8 +64,11 @@ class AnsibleService: ...@@ -64,8 +64,11 @@ class AnsibleService:
if application.name == 'gluster_fs' or application.name == 'glusterfs' or application.name == 'tic': if application.name == 'gluster_fs' or application.name == 'glusterfs' or application.name == 'tic':
arguments = '["-u","vm_user"]' arguments = '["-u","vm_user"]'
if playbook_name == '013.mount_fs.yml': if playbook_name == '013.mount_fs.yml':
master_ip = next(iter( for vm in vms:
inventory_dict['all']['children']['swarm_manager_prime']['hosts'])) attributes = vm.node_template.attributes
if attributes['role'] == 'master':
master_ip = attributes['public_ip']
break
arguments = '["-u","vm_user","--extra-vars","gluster_cluster_host0=\'' + master_ip + '\' gluster_cluster_volume=\'gfs0\'"]' arguments = '["-u","vm_user","--extra-vars","gluster_cluster_host0=\'' + master_ip + '\' gluster_cluster_volume=\'gfs0\'"]'
task_id = self.run_task(name, project_id, key_id, git_url, inventory_id, playbook_name, task_id = self.run_task(name, project_id, key_id, git_url, inventory_id, playbook_name,
environment_id=environment_id, arguments=arguments) environment_id=environment_id, arguments=arguments)
...@@ -173,22 +176,28 @@ class AnsibleService: ...@@ -173,22 +176,28 @@ class AnsibleService:
inventory = {} inventory = {}
all = {} all = {}
children = {} children = {}
gfs_count = 1
for vm in vms: for vm in vms:
attributes = vm.node_template.attributes attributes = vm.node_template.attributes
roles = [] roles = []
roles.append('gfscluster') roles.append('gfscluster')
public_ip = attributes['public_ip'] public_ip = attributes['public_ip']
vm_vars = {'ansible_host': public_ip}
vm_vars.update(vars)
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:
hosts['hosts'][public_ip] = vars hosts['hosts']['gfs' + str(gfs_count)] = vm_vars
else: else:
host = {} host = {}
host[public_ip] = vars host['gfs' + str(gfs_count)] = vm_vars
hosts['hosts'] = host hosts['hosts'] = host
gfs_count += 1
children[role] = hosts children[role] = hosts
all['children'] = children all['children'] = children
inventory['all'] = all inventory['all'] = all
......
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