Avoid erroring on host group confusion in keyed groups (#54099)

This commit is contained in:
Alan Rominger
2019-03-25 16:57:46 -04:00
committed by Brian Coca
parent 54be769e8d
commit f2f11341a3
2 changed files with 21 additions and 1 deletions

View File

@@ -93,6 +93,26 @@ def test_keyed_group_empty_construction(inventory_module):
assert host.groups == []
def test_keyed_group_host_confusion(inventory_module):
inventory_module.inventory.add_host('cow')
inventory_module.inventory.add_group('cow')
host = inventory_module.inventory.get_host('cow')
host.vars['species'] = 'cow'
keyed_groups = [
{
'separator': '',
'prefix': '',
'key': 'species'
}
]
inventory_module._add_host_to_keyed_groups(
keyed_groups, host.vars, host.name, strict=True
)
group = inventory_module.inventory.groups['cow']
# group cow has host of cow
assert group.hosts == [host]
def test_keyed_parent_groups(inventory_module):
inventory_module.inventory.add_host('web1')
inventory_module.inventory.add_host('web2')