|
|
|
@ -17,7 +17,7 @@
|
|
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
|
|
|
|
|
|
from ansible.utils import template
|
|
|
|
|
from ansible.utils.template import template, smush_braces
|
|
|
|
|
from ansible import utils
|
|
|
|
|
from ansible import errors
|
|
|
|
|
from ansible.playbook.task import Task
|
|
|
|
@ -69,7 +69,7 @@ class Play(object):
|
|
|
|
|
# tasks/handlers as they may have inventory scope overrides
|
|
|
|
|
_tasks = ds.pop('tasks', [])
|
|
|
|
|
_handlers = ds.pop('handlers', [])
|
|
|
|
|
ds = template.template(basedir, ds, self.vars)
|
|
|
|
|
ds = template(basedir, ds, self.vars)
|
|
|
|
|
ds['tasks'] = _tasks
|
|
|
|
|
ds['handlers'] = _handlers
|
|
|
|
|
|
|
|
|
@ -239,7 +239,7 @@ class Play(object):
|
|
|
|
|
task_vars['_original_file'] = original_file
|
|
|
|
|
|
|
|
|
|
if 'include' in x:
|
|
|
|
|
tokens = shlex.split(str(x['include']))
|
|
|
|
|
tokens = shlex.split(smush_braces(str(x['include'])))
|
|
|
|
|
items = ['']
|
|
|
|
|
included_additional_conditions = list(additional_conditions)
|
|
|
|
|
for k in x:
|
|
|
|
@ -247,7 +247,7 @@ class Play(object):
|
|
|
|
|
plugin_name = k[5:]
|
|
|
|
|
if plugin_name not in utils.plugins.lookup_loader:
|
|
|
|
|
raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name))
|
|
|
|
|
terms = template.template(self.basedir, x[k], task_vars)
|
|
|
|
|
terms = template(self.basedir, x[k], task_vars)
|
|
|
|
|
items = utils.plugins.lookup_loader.get(plugin_name, basedir=self.basedir, runner=None).run(terms, inject=task_vars)
|
|
|
|
|
elif k.startswith("when_"):
|
|
|
|
|
included_additional_conditions.append(utils.compile_when_to_only_if("%s %s" % (k[5:], x[k])))
|
|
|
|
@ -268,11 +268,11 @@ class Play(object):
|
|
|
|
|
mv['item'] = item
|
|
|
|
|
for t in tokens[1:]:
|
|
|
|
|
(k,v) = t.split("=", 1)
|
|
|
|
|
mv[k] = template.template(self.basedir, v, mv)
|
|
|
|
|
mv[k] = template(self.basedir, v, mv)
|
|
|
|
|
dirname = self.basedir
|
|
|
|
|
if original_file:
|
|
|
|
|
dirname = os.path.dirname(original_file)
|
|
|
|
|
include_file = template.template(dirname, tokens[0], mv)
|
|
|
|
|
include_file = template(dirname, tokens[0], mv)
|
|
|
|
|
include_filename = utils.path_dwim(dirname, include_file)
|
|
|
|
|
data = utils.parse_yaml_from_file(include_filename)
|
|
|
|
|
results += self._load_tasks(data, mv, included_additional_conditions, original_file=include_filename)
|
|
|
|
@ -415,10 +415,10 @@ class Play(object):
|
|
|
|
|
found = False
|
|
|
|
|
sequence = []
|
|
|
|
|
for real_filename in filename:
|
|
|
|
|
filename2 = template.template(self.basedir, real_filename, self.vars)
|
|
|
|
|
filename2 = template(self.basedir, real_filename, self.vars)
|
|
|
|
|
filename3 = filename2
|
|
|
|
|
if host is not None:
|
|
|
|
|
filename3 = template.template(self.basedir, filename2, inject)
|
|
|
|
|
filename3 = template(self.basedir, filename2, inject)
|
|
|
|
|
filename4 = utils.path_dwim(self.basedir, filename3)
|
|
|
|
|
sequence.append(filename4)
|
|
|
|
|
if os.path.exists(filename4):
|
|
|
|
@ -448,10 +448,10 @@ class Play(object):
|
|
|
|
|
else:
|
|
|
|
|
# just one filename supplied, load it!
|
|
|
|
|
|
|
|
|
|
filename2 = template.template(self.basedir, filename, self.vars)
|
|
|
|
|
filename2 = template(self.basedir, filename, self.vars)
|
|
|
|
|
filename3 = filename2
|
|
|
|
|
if host is not None:
|
|
|
|
|
filename3 = template.template(self.basedir, filename2, inject)
|
|
|
|
|
filename3 = template(self.basedir, filename2, inject)
|
|
|
|
|
filename4 = utils.path_dwim(self.basedir, filename3)
|
|
|
|
|
if self._has_vars_in(filename4):
|
|
|
|
|
continue
|
|
|
|
|