mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Avoid erroring on host group confusion in keyed groups (#54099)
This commit is contained in:
committed by
Brian Coca
parent
54be769e8d
commit
f2f11341a3
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user