1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Tweak such that all INI groups don't get added directly to all.

This commit is contained in:
Michael DeHaan 2013-07-14 16:34:51 -04:00
parent 43415947d0
commit 3054be117e

View File

@ -52,14 +52,16 @@ class MemGroup(object):
LOGGER.debug("loading group_vars") LOGGER.debug("loading group_vars")
self.variables = yaml.load(open(group_vars).read()) self.variables = yaml.load(open(group_vars).read())
def child_group_by_name(self, grp_name): def child_group_by_name(self, grp_name, loader):
LOGGER.debug("looking for child group: %s" % grp_name) LOGGER.debug("looking for child group: %s" % grp_name)
if grp_name == 'all': if grp_name == 'all':
return return
# slight hack here, passing in 'self' for all_group but child=True won't use it
grp = loader.get_group(grp_name, self, child=True)
# don't add to child groups if already there
for x in self.child_groups: for x in self.child_groups:
if x.name == grp_name: if x.name == grp_name:
return x return x
grp = MemGroup(grp_name, self.inventory_base)
LOGGER.debug("adding child group %s to group %s" % (grp.name, self.name)) LOGGER.debug("adding child group %s to group %s" % (grp.name, self.name))
self.child_groups.append(grp) self.child_groups.append(grp)
return grp return grp
@ -202,7 +204,7 @@ class IniLoader(BaseLoader):
group.add_host(new_host) group.add_host(new_host)
elif input_mode == 'children': elif input_mode == 'children':
group.child_group_by_name(line) group.child_group_by_name(line, self)
elif input_mode == 'vars': elif input_mode == 'vars':
for t in tokens: for t in tokens:
(k, v) = t.split("=", 1) (k, v) = t.split("=", 1)