do not error in case of empty list constructed group (#53748)

This commit is contained in:
Alan Rominger 2019-03-14 12:27:56 -04:00 committed by Brian Coca
parent 14d670573a
commit 8c2037aaa9
2 changed files with 23 additions and 7 deletions

View file

@ -429,7 +429,9 @@ class Constructable(object):
self.inventory.add_child(parent_name, result_gname)
else:
if strict:
raise AnsibleParserError("No key or key resulted empty, invalid entry")
# exclude case of empty list and dictionary, because these are valid constructions
# simply no groups need to be constructed, but are still falsy
if strict and key not in ([], {}):
raise AnsibleParserError("No key or key resulted empty for %s in host %s, invalid entry" % (keyed.get('key'), host))
else:
raise AnsibleParserError("Invalid keyed group entry, it must be a dictionary: %s " % keyed)