When using roles, or other includes, the path to DWIM inside is the path of the task include

file.
This commit is contained in:
Michael DeHaan 2013-04-06 18:32:36 -04:00
parent f88d13acf9
commit f044fc344b
2 changed files with 11 additions and 3 deletions

View file

@ -3,4 +3,8 @@
- name: blippy
shell: echo notifier called, and the value of x is '{{ x }}'
# within a role, it's possible to include other task files as well. By default, we
# can reference files in the same directory without doing anything special:
- include: other.yml

View file

@ -223,9 +223,13 @@ class Play(object):
for t in tokens[1:]:
(k,v) = t.split("=", 1)
mv[k] = utils.template(self.basedir, v, mv)
include_file = utils.template(self.basedir, tokens[0], mv)
data = utils.parse_yaml_from_file(utils.path_dwim(self.basedir, include_file))
results += self._load_tasks(data, mv, included_additional_conditions, original_file=include_file)
dirname = self.basedir
if original_file:
dirname = os.path.dirname(original_file)
include_file = utils.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)
elif type(x) == dict:
results.append(Task(self,x,module_vars=task_vars, additional_conditions=additional_conditions))
else: