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

ini plugin should recursively instantiate pending

solves inconsistent behaviour on ini host format depending on definition order
fixes #32196
This commit is contained in:
Brian Coca 2017-11-01 17:48:50 -04:00 committed by Brian Coca
parent 9a13bf9bff
commit 9d28973b5e

View file

@ -193,9 +193,7 @@ class InventoryModule(BaseFileInventoryPlugin):
if groupname in pending_declarations and state != 'vars':
if pending_declarations[groupname]['state'] == 'children':
for parent in pending_declarations[groupname]['parents']:
self.inventory.add_child(parent, groupname)
del pending_declarations[groupname]
self._add_pending_children(groupname, pending_declarations)
continue
elif line.startswith('[') and line.endswith(']'):
@ -248,6 +246,13 @@ class InventoryModule(BaseFileInventoryPlugin):
elif decl['state'] == 'children':
raise AnsibleError("%s:%d: Section [%s:children] includes undefined group: %s" % (path, decl['line'], decl['parents'].pop(), decl['name']))
def _add_pending_children(self, group, pending):
for parent in pending[group]['parents']:
self.inventory.add_child(parent, group)
if parent in pending and pending[parent]['state'] == 'children':
self._add_pending_children(parent, pending)
del pending[group]
def _parse_group_name(self, line):
'''
Takes a single line and tries to parse it as a group name. Returns the