diff --git a/playbooks/inventory/dynamic_inventory.py b/playbooks/inventory/dynamic_inventory.py index 9a7d54b67f..4bdf21ad06 100755 --- a/playbooks/inventory/dynamic_inventory.py +++ b/playbooks/inventory/dynamic_inventory.py @@ -231,7 +231,7 @@ def _build_container_hosts(container_affinity, container_hosts, type_and_name, address = host_type_config.get('ip') # Create a host types containers group and append it to inventory - host_type_containers = '%s_containers' % host_type + host_type_containers = '%s-host_containers' % host_type append_if(array=container_mapping, item=host_type_containers) hostvars_options.update({ @@ -373,7 +373,7 @@ def _add_container_hosts(assignment, config, container_name, container_type, ) physical_host = inventory['_meta']['hostvars'][host_type] - container_host_type = '%s_containers' % host_type + container_host_type = '%s-host_containers' % host_type if 'container_types' not in physical_host: physical_host['container_types'] = container_host_type elif physical_host['container_types'] != container_host_type: diff --git a/releasenotes/notes/inventory_host_containers_naming-d1f42a0c91d68154.yaml b/releasenotes/notes/inventory_host_containers_naming-d1f42a0c91d68154.yaml new file mode 100644 index 0000000000..29a26ac39d --- /dev/null +++ b/releasenotes/notes/inventory_host_containers_naming-d1f42a0c91d68154.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - Changed the way we name host containers groups in + dynamic_inventory.py for a hostname from + hostname_containers to hostname-host_containers to + prevent failing in the case where containers groups + have the same name as host containers when choosing + hostnames inspired from containers group names. This + change fixes the following bugs + https://bugs.launchpad.net/openstack-ansible/+bug/1512883 and + https://bugs.launchpad.net/openstack-ansible/+bug/1528953. diff --git a/tests/test_inventory.py b/tests/test_inventory.py index 3798284a12..d15bb3fe87 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -69,7 +69,7 @@ class TestAnsibleInventoryFormatConstraints(unittest.TestCase): inventory = None expected_groups = [ - 'aio1_containers', + 'aio1-host_containers', 'all', 'all_containers', 'aodh_alarm_evaluator',