inventory ini parser: do not add all the groups to *all* group
but only those with lowest depth, so we keep a proper tree structure
This commit is contained in:
parent
cc8efb4aab
commit
0ceefbbf29
1 changed files with 8 additions and 2 deletions
|
@ -45,6 +45,7 @@ class InventoryParser(object):
|
||||||
|
|
||||||
self._parse_base_groups()
|
self._parse_base_groups()
|
||||||
self._parse_group_children()
|
self._parse_group_children()
|
||||||
|
self._add_allgroup_children()
|
||||||
self._parse_group_variables()
|
self._parse_group_variables()
|
||||||
return self.groups
|
return self.groups
|
||||||
|
|
||||||
|
@ -69,6 +70,13 @@ class InventoryParser(object):
|
||||||
# gamma sudo=True user=root
|
# gamma sudo=True user=root
|
||||||
# delta asdf=jkl favcolor=red
|
# delta asdf=jkl favcolor=red
|
||||||
|
|
||||||
|
def _add_allgroup_children(self):
|
||||||
|
|
||||||
|
for group in self.groups.values():
|
||||||
|
if group.depth == 0 and group.name != 'all':
|
||||||
|
self.groups['all'].add_child_group(group)
|
||||||
|
|
||||||
|
|
||||||
def _parse_base_groups(self):
|
def _parse_base_groups(self):
|
||||||
# FIXME: refactor
|
# FIXME: refactor
|
||||||
|
|
||||||
|
@ -87,11 +95,9 @@ class InventoryParser(object):
|
||||||
active_group_name = active_group_name.rsplit(":", 1)[0]
|
active_group_name = active_group_name.rsplit(":", 1)[0]
|
||||||
if active_group_name not in self.groups:
|
if active_group_name not in self.groups:
|
||||||
new_group = self.groups[active_group_name] = Group(name=active_group_name)
|
new_group = self.groups[active_group_name] = Group(name=active_group_name)
|
||||||
all.add_child_group(new_group)
|
|
||||||
active_group_name = None
|
active_group_name = None
|
||||||
elif active_group_name not in self.groups:
|
elif active_group_name not in self.groups:
|
||||||
new_group = self.groups[active_group_name] = Group(name=active_group_name)
|
new_group = self.groups[active_group_name] = Group(name=active_group_name)
|
||||||
all.add_child_group(new_group)
|
|
||||||
elif line.startswith(";") or line == '':
|
elif line.startswith(";") or line == '':
|
||||||
pass
|
pass
|
||||||
elif active_group_name:
|
elif active_group_name:
|
||||||
|
|
Loading…
Reference in a new issue