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
This commit is contained in:
Ala Raddaoui 2016-02-22 15:57:15 +00:00
parent cb4e4d219b
commit 16c0193a13
3 changed files with 14 additions and 3 deletions

View File

@ -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:

View File

@ -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.

View File

@ -69,7 +69,7 @@ class TestAnsibleInventoryFormatConstraints(unittest.TestCase):
inventory = None
expected_groups = [
'aio1_containers',
'aio1-host_containers',
'all',
'all_containers',
'aodh_alarm_evaluator',