From 16c0193a131cc450b22b6a81b26757a0de32ac76 Mon Sep 17 00:00:00 2001 From: Ala Raddaoui Date: Mon, 22 Feb 2016 15:57:15 +0000 Subject: [PATCH] change host_containers group names in inventory In user config, when choosing host names inspired from containers group names, this will lead in the code to have host_containers to be identical to group_containers. This will eventually lead to unintentially having groups added to itselves in the inventory which will lead to unending recursion loop in the dynamic_inventory.py. Changing the way we construct the name of host_containers will prevent that. Change-Id: I5edb6091cb10588099f023f3ae961ed714aea2ce Closes-Bug: 1512883 Closes-Bug: 1528953 --- playbooks/inventory/dynamic_inventory.py | 4 ++-- ...ntory_host_containers_naming-d1f42a0c91d68154.yaml | 11 +++++++++++ tests/test_inventory.py | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/inventory_host_containers_naming-d1f42a0c91d68154.yaml 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',