mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
Make group_vars and host_vars available to usr/bin/ansible, and make vars_plugins exist
This commit is contained in:
parent
e04dab904a
commit
6ba30170dd
9 changed files with 91 additions and 29 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue