make groups magic var dependant on inventory (#28677)

* make groups magic var dependant on inventory

it was overtly restricted by 'host'
minor fixes to test_var_manager.py, need to test other values also

* pepe hates extra blank line
This commit is contained in:
Brian Coca
2017-08-28 17:21:11 -04:00
committed by GitHub
parent de6ba4daff
commit f9b3f4f934
2 changed files with 6 additions and 11 deletions

View File

@@ -457,10 +457,6 @@ class VariableManager:
variables['playbook_dir'] = os.path.abspath(self._loader.get_basedir())
variables['ansible_playbook_python'] = sys.executable
if host:
# host already provides some magic vars via host.get_vars()
if self._inventory:
variables['groups'] = self._inventory.get_groups_dict()
if play:
variables['role_names'] = [r._role_name for r in play.roles]
@@ -471,6 +467,7 @@ class VariableManager:
variables['role_uuid'] = text_type(task._role._uuid)
if self._inventory is not None:
variables['groups'] = self._inventory.get_groups_dict()
if play:
templar = Templar(loader=self._loader)
if templar.is_template(play.hosts):