Make group_vars and host_vars available to usr/bin/ansible, and make vars_plugins exist

This commit is contained in:
Michael DeHaan 2012-10-26 19:55:59 -04:00
parent e04dab904a
commit 6ba30170dd
9 changed files with 91 additions and 29 deletions

View file

@ -242,29 +242,6 @@ class Play(object):
if type(self.vars_files) != list:
self.vars_files = [ self.vars_files ]
if (host is not None):
self.playbook.SETUP_CACHE[host].update(self.vars)
inventory = self.playbook.inventory
hostrec = inventory.get_host(host)
groupz = sorted(inventory.groups_for_host(host), key=lambda g: g.depth)
groups = [ g.name for g in groupz ]
basedir = inventory.basedir()
if basedir is not None:
for x in groups:
path = os.path.join(basedir, "group_vars/%s" % x)
if os.path.exists(path):
data = utils.parse_yaml_from_file(path)
if type(data) != dict:
raise errors.AnsibleError("%s must be stored as a dictionary/hash" % path)
self.playbook.SETUP_CACHE[host].update(data)
path = os.path.join(basedir, "host_vars/%s" % hostrec.name)
if os.path.exists(path):
data = utils.parse_yaml_from_file(path)
if type(data) != dict:
raise errors.AnsibleError("%s must be stored as a dictionary/hash" % path)
self.playbook.SETUP_CACHE[host].update(data)
for filename in self.vars_files:
if type(filename) == list: