Merge "Add role_data* keys to inventory"
This commit is contained in:
commit
be8a437a78
@ -194,6 +194,7 @@ class TripleoInventory(object):
|
|||||||
role_net_ip_map = self.stack_outputs.get('RoleNetIpMap', {})
|
role_net_ip_map = self.stack_outputs.get('RoleNetIpMap', {})
|
||||||
role_node_id_map = self.stack_outputs.get('ServerIdData', {})
|
role_node_id_map = self.stack_outputs.get('ServerIdData', {})
|
||||||
networks = set()
|
networks = set()
|
||||||
|
role_data = self.stack_outputs.get('RoleData', {})
|
||||||
role_net_hostname_map = self.stack_outputs.get(
|
role_net_hostname_map = self.stack_outputs.get(
|
||||||
'RoleNetHostnameMap', {})
|
'RoleNetHostnameMap', {})
|
||||||
children = []
|
children = []
|
||||||
@ -228,6 +229,16 @@ class TripleoInventory(object):
|
|||||||
'role_name': role,
|
'role_name': role,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# Note we add each individual key from role_data, because if
|
||||||
|
# any template sections define inline ansible with j2 variables
|
||||||
|
# ansible silently treats those inventory variables as
|
||||||
|
# undefined
|
||||||
|
# This at least means we can consume those keys which don't
|
||||||
|
# have this problem (in general we don't need the nested
|
||||||
|
# ansible *tasks because these are available via config
|
||||||
|
# download already)
|
||||||
|
for k in role_data[role]:
|
||||||
|
ret[role]['vars']["role_data_%s" % k] = role_data[role][k]
|
||||||
|
|
||||||
if children:
|
if children:
|
||||||
vip_map = self.stack_outputs.get('VipMap', {})
|
vip_map = self.stack_outputs.get('VipMap', {})
|
||||||
|
@ -93,7 +93,12 @@ class TestInventory(base.TestCase):
|
|||||||
{'output_key': 'VipMap',
|
{'output_key': 'VipMap',
|
||||||
'output_value': {
|
'output_value': {
|
||||||
'ctlplane': 'x.x.x.4',
|
'ctlplane': 'x.x.x.4',
|
||||||
'redis': 'x.x.x.6'}}]}
|
'redis': 'x.x.x.6'}},
|
||||||
|
{'output_key': 'RoleData',
|
||||||
|
'output_value': {
|
||||||
|
'Controller': {'config_settings': 'foo1'},
|
||||||
|
'Compute': {'config_settings': 'foo2'},
|
||||||
|
'CustomRole': {'config_settings': 'foo3'}}}]}
|
||||||
self.plan_name = 'overcloud'
|
self.plan_name = 'overcloud'
|
||||||
|
|
||||||
self.hclient = MagicMock()
|
self.hclient = MagicMock()
|
||||||
@ -159,7 +164,8 @@ class TestInventory(base.TestCase):
|
|||||||
def test_outputs_iterating_returns_list_of_output_keys(self):
|
def test_outputs_iterating_returns_list_of_output_keys(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'EnabledServices', 'KeystoneURL', 'ServerIdData',
|
{'EnabledServices', 'KeystoneURL', 'ServerIdData',
|
||||||
'RoleNetHostnameMap', 'RoleNetIpMap', 'VipMap'},
|
'RoleNetHostnameMap', 'RoleNetIpMap', 'VipMap',
|
||||||
|
'RoleData'},
|
||||||
set([o for o in self.outputs]))
|
set([o for o in self.outputs]))
|
||||||
|
|
||||||
def test_inventory_list(self):
|
def test_inventory_list(self):
|
||||||
@ -196,11 +202,13 @@ class TestInventory(base.TestCase):
|
|||||||
'children': ['cp-0'],
|
'children': ['cp-0'],
|
||||||
'vars': {'ansible_ssh_user': 'heat-admin',
|
'vars': {'ansible_ssh_user': 'heat-admin',
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo2',
|
||||||
'role_name': 'Compute'}},
|
'role_name': 'Compute'}},
|
||||||
'Controller': {
|
'Controller': {
|
||||||
'children': ['c-0', 'c-1', 'c-2'],
|
'children': ['c-0', 'c-1', 'c-2'],
|
||||||
'vars': {'ansible_ssh_user': 'heat-admin',
|
'vars': {'ansible_ssh_user': 'heat-admin',
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo1',
|
||||||
'role_name': 'Controller'}},
|
'role_name': 'Controller'}},
|
||||||
'cp-0': {'hosts': ['y.y.y.1'],
|
'cp-0': {'hosts': ['y.y.y.1'],
|
||||||
'vars': {'deploy_server_id': 'd',
|
'vars': {'deploy_server_id': 'd',
|
||||||
@ -214,6 +222,7 @@ class TestInventory(base.TestCase):
|
|||||||
'children': ['cs-0'],
|
'children': ['cs-0'],
|
||||||
'vars': {'ansible_ssh_user': 'heat-admin',
|
'vars': {'ansible_ssh_user': 'heat-admin',
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo3',
|
||||||
'role_name': 'CustomRole'}},
|
'role_name': 'CustomRole'}},
|
||||||
'overcloud': {
|
'overcloud': {
|
||||||
'children': ['Compute', 'Controller', 'CustomRole'],
|
'children': ['Compute', 'Controller', 'CustomRole'],
|
||||||
@ -282,11 +291,13 @@ class TestInventory(base.TestCase):
|
|||||||
'children': ['cp-0'],
|
'children': ['cp-0'],
|
||||||
'vars': {'ansible_ssh_user': ansible_ssh_user,
|
'vars': {'ansible_ssh_user': ansible_ssh_user,
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo2',
|
||||||
'role_name': 'Compute'}},
|
'role_name': 'Compute'}},
|
||||||
'Controller': {
|
'Controller': {
|
||||||
'children': ['c-0', 'c-1', 'c-2'],
|
'children': ['c-0', 'c-1', 'c-2'],
|
||||||
'vars': {'ansible_ssh_user': ansible_ssh_user,
|
'vars': {'ansible_ssh_user': ansible_ssh_user,
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo1',
|
||||||
'role_name': 'Controller'}},
|
'role_name': 'Controller'}},
|
||||||
'cp-0': {'hosts': ['y.y.y.1'],
|
'cp-0': {'hosts': ['y.y.y.1'],
|
||||||
'vars': {'deploy_server_id': 'd',
|
'vars': {'deploy_server_id': 'd',
|
||||||
@ -300,6 +311,7 @@ class TestInventory(base.TestCase):
|
|||||||
'children': ['cs-0'],
|
'children': ['cs-0'],
|
||||||
'vars': {'ansible_ssh_user': ansible_ssh_user,
|
'vars': {'ansible_ssh_user': ansible_ssh_user,
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo3',
|
||||||
'role_name': 'CustomRole'}},
|
'role_name': 'CustomRole'}},
|
||||||
'overcloud': {
|
'overcloud': {
|
||||||
'children': ['Compute', 'Controller', 'CustomRole'],
|
'children': ['Compute', 'Controller', 'CustomRole'],
|
||||||
@ -347,14 +359,17 @@ class TestInventory(base.TestCase):
|
|||||||
'Compute': {'children': {'cp-0': {}},
|
'Compute': {'children': {'cp-0': {}},
|
||||||
'vars': {'ansible_ssh_user': 'heat-admin',
|
'vars': {'ansible_ssh_user': 'heat-admin',
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo2',
|
||||||
'role_name': 'Compute'}},
|
'role_name': 'Compute'}},
|
||||||
'Controller': {'children': {'c-0': {}, 'c-1': {}, 'c-2': {}},
|
'Controller': {'children': {'c-0': {}, 'c-1': {}, 'c-2': {}},
|
||||||
'vars': {'ansible_ssh_user': 'heat-admin',
|
'vars': {'ansible_ssh_user': 'heat-admin',
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo1',
|
||||||
'role_name': 'Controller'}},
|
'role_name': 'Controller'}},
|
||||||
'CustomRole': {'children': {'cs-0': {}},
|
'CustomRole': {'children': {'cs-0': {}},
|
||||||
'vars': {'ansible_ssh_user': 'heat-admin',
|
'vars': {'ansible_ssh_user': 'heat-admin',
|
||||||
'bootstrap_server_id': 'a',
|
'bootstrap_server_id': 'a',
|
||||||
|
'role_data_config_settings': 'foo3',
|
||||||
'role_name': 'CustomRole'}},
|
'role_name': 'CustomRole'}},
|
||||||
'_meta': {'hostvars': {}},
|
'_meta': {'hostvars': {}},
|
||||||
'c-0': {'hosts': {'x.x.x.1': {}},
|
'c-0': {'hosts': {'x.x.x.1': {}},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user