1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Allow InventoryScript JSON with childgroups only

and without hosts and vars

Without this patch, the simplified syntax is triggered when a group
is defined like this:

    "platforms": {
        "children": [
            "cloudstack"
        ]
    }

Which results in a group 'platforms' with 1 host 'platforms'.

more details in https://github.com/ansible/ansible/issues/13655
This commit is contained in:
Emil Lind 2016-01-08 13:52:44 +01:00
parent 45355cd566
commit b0fe705384

View file

@ -103,7 +103,7 @@ class InventoryScript:
if not isinstance(data, dict): if not isinstance(data, dict):
data = {'hosts': data} data = {'hosts': data}
# is not those subkeys, then simplified syntax, host with vars # is not those subkeys, then simplified syntax, host with vars
elif not any(k in data for k in ('hosts','vars')): elif not any(k in data for k in ('hosts','vars','children')):
data = {'hosts': [group_name], 'vars': data} data = {'hosts': [group_name], 'vars': data}
if 'hosts' in data: if 'hosts' in data: