Add per-network bind ips to inventory

This adds the per-node per-network ips for each network so we
can e.g set the bind ips for services deployed via ansible.

Change-Id: I6085df4741d944875afbe02d71b9e9a85c406024
This commit is contained in:
Steven Hardy 2017-11-01 16:59:56 +00:00 committed by Jiri Stransky
parent bcbc953aa2
commit 8d86b0dbfb
2 changed files with 24 additions and 10 deletions

View File

@ -170,6 +170,10 @@ class TripleoInventory(object):
ret[name]['vars'] = {
'deploy_server_id': role_node_id_map[
'server_ids'][role][idx]}
# Add variable for IP on each network
for net in role_net_ip_map[role]:
ret[name]['vars']["%s_ip" % net] = \
role_net_ip_map[role][net][idx]
children.append(role)
ret[role] = {

View File

@ -157,11 +157,14 @@ class TestInventory(base.TestCase):
def test_inventory_list(self):
expected = {'c-0': {'hosts': ['x.x.x.1'],
'vars': {'deploy_server_id': 'a'}},
'vars': {'deploy_server_id': 'a',
'ctlplane_ip': 'x.x.x.1'}},
'c-1': {'hosts': ['x.x.x.2'],
'vars': {'deploy_server_id': 'b'}},
'vars': {'deploy_server_id': 'b',
'ctlplane_ip': 'x.x.x.2'}},
'c-2': {'hosts': ['x.x.x.3'],
'vars': {'deploy_server_id': 'c'}},
'vars': {'deploy_server_id': 'c',
'ctlplane_ip': 'x.x.x.3'}},
'Compute': {
'children': ['cp-0'],
'vars': {'ansible_ssh_user': 'heat-admin',
@ -173,9 +176,11 @@ class TestInventory(base.TestCase):
'bootstrap_server_id': 'a',
'role_name': 'Controller'}},
'cp-0': {'hosts': ['y.y.y.1'],
'vars': {'deploy_server_id': 'd'}},
'vars': {'deploy_server_id': 'd',
'ctlplane_ip': 'y.y.y.1'}},
'cs-0': {'hosts': ['z.z.z.1'],
'vars': {'deploy_server_id': 'e'}},
'vars': {'deploy_server_id': 'e',
'ctlplane_ip': 'z.z.z.1'}},
'CustomRole': {
'children': ['cs-0'],
'vars': {'ansible_ssh_user': 'heat-admin',
@ -213,11 +218,14 @@ class TestInventory(base.TestCase):
self.inventory.stack_outputs = self.outputs
expected = {'c-0': {'hosts': ['x.x.x.1'],
'vars': {'deploy_server_id': 'a'}},
'vars': {'deploy_server_id': 'a',
'ctlplane_ip': 'x.x.x.1'}},
'c-1': {'hosts': ['x.x.x.2'],
'vars': {'deploy_server_id': 'b'}},
'vars': {'deploy_server_id': 'b',
'ctlplane_ip': 'x.x.x.2'}},
'c-2': {'hosts': ['x.x.x.3'],
'vars': {'deploy_server_id': 'c'}},
'vars': {'deploy_server_id': 'c',
'ctlplane_ip': 'x.x.x.3'}},
'Compute': {
'children': ['cp-0'],
'vars': {'ansible_ssh_user': 'my-custom-admin',
@ -229,9 +237,11 @@ class TestInventory(base.TestCase):
'bootstrap_server_id': 'a',
'role_name': 'Controller'}},
'cp-0': {'hosts': ['y.y.y.1'],
'vars': {'deploy_server_id': 'd'}},
'vars': {'deploy_server_id': 'd',
'ctlplane_ip': 'y.y.y.1'}},
'cs-0': {'hosts': ['z.z.z.1'],
'vars': {'deploy_server_id': 'e'}},
'vars': {'deploy_server_id': 'e',
'ctlplane_ip': 'z.z.z.1'}},
'CustomRole': {
'children': ['cs-0'],
'vars': {'ansible_ssh_user': 'my-custom-admin',