Introduce group_names in template variables.

This is a list of all the groups a host is in.
This commit is contained in:
Jeroen Hoekx 2012-04-28 18:23:44 +02:00
parent 6341361a5b
commit b87710a1df
3 changed files with 33 additions and 11 deletions

View file

@ -81,13 +81,19 @@ class Inventory(object):
def get_variables(self, host):
""" Return the variables associated with this host. """
variables = {}
if host in self._variables:
return self._variables[host].copy()
variables.update(self._variables[host].copy())
if not self._is_script:
return {}
if self._is_script:
variables.update(self._get_variables_from_script(host))
return self._get_variables_from_script(host)
variables['group_names'] = []
for name,hosts in self.groups.iteritems():
if host in hosts:
variables['group_names'].append(name)
return variables
# *****************************************************