diff --git a/tripleo_common/inventory.py b/tripleo_common/inventory.py index 467ef8635..0c0157dbe 100644 --- a/tripleo_common/inventory.py +++ b/tripleo_common/inventory.py @@ -285,6 +285,27 @@ class TripleoInventory(object): # Associate services with roles roles_by_service = self.get_roles_by_service( self.stack_outputs.get('EnabledServices', {})) + + # tripleo-groups map to ceph-ansible groups as follows + ceph_group_map = { + 'ceph_mon': 'mons', + 'ceph_osd': 'osds', + 'ceph_mgr': 'mgrs', + 'ceph_rgw': 'rgws', + 'ceph_mds': 'mdss', + 'ceph_nfs': 'nfss', + 'ceph_client': 'clients', + 'ceph_rbdmirror': 'rbdmirrors' + } + # add a ceph-ansible compatible group to the inventory + # which has the same roles. E.g. if the inventory has + # a group 'ceph_mon' which has childen and vars, then + # the inventory will now also have a group 'mons' with + # the same children and vars. + for service, roles in roles_by_service.copy().items(): + if service in ceph_group_map.keys(): + roles_by_service[ceph_group_map[service]] = roles + for service, roles in roles_by_service.items(): service_children = [role for role in roles if ret.get(role) is not None] diff --git a/tripleo_common/tests/test_inventory.py b/tripleo_common/tests/test_inventory.py index 244505cae..254c2e7c6 100644 --- a/tripleo_common/tests/test_inventory.py +++ b/tripleo_common/tests/test_inventory.py @@ -39,7 +39,8 @@ MOCK_ENABLED_SERVICES = { "Compute": [ "nova_compute", "kernel", - "tripleo_packages" + "tripleo_packages", + "ceph_client" ], "CephStorage": [ "kernel", @@ -60,7 +61,7 @@ class TestInventory(base.TestCase): {'output_key': 'EnabledServices', 'output_value': { 'Controller': ['sa', 'sb'], - 'Compute': ['sd', 'se'], + 'Compute': ['sd', 'se', 'ceph_client'], 'CustomRole': ['sg', 'sh']}}, {'output_key': 'KeystoneURL', 'output_value': 'xyz://keystone'}, @@ -138,6 +139,7 @@ class TestInventory(base.TestCase): 'keystone': ['Controller'], 'nova_compute': ['Compute'], 'cinder_volume': ['BlockStorage'], + 'ceph_client': ['Compute'], } self.assertDictEqual(services, expected) @@ -398,6 +400,10 @@ class TestInventory(base.TestCase): 'vars': {'ansible_ssh_user': 'heat-admin'}}, 'se': {'children': {'Compute': {}}, 'vars': {'ansible_ssh_user': 'heat-admin'}}, + 'ceph_client': {'children': {'Compute': {}}, + 'vars': {'ansible_ssh_user': 'heat-admin'}}, + 'clients': {'children': {'Compute': {}}, + 'vars': {'ansible_ssh_user': 'heat-admin'}}, 'sg': {'children': {'CustomRole': {}}, 'vars': {'ansible_ssh_user': 'heat-admin'}}, 'sh': {'children': {'CustomRole': {}},