fix searched paths in DataLoader.path_dwim_relative (avoid AnsibleFileNotFound) (#26729)

* add unit test: nested dynamic includes

* nested dynamic includes: avoid AnsibleFileNotFound error

Error was:
Unable to retrieve file contents
Could not find or access 'include2.yml'

Before 8f758204cf, at the end of
'path_dwim_relative' method, the 'search' variable contained amongst
others paths:
'/tmp/roles/testrole/tasks/tasks/included.yml' and
'/tmp/roles/testrole/tasks/included.yml'.
The commit mentioned before removed the last one despite the method
docstrings specify 'with or without explicitly named dirname subdirs'.

* add integration test: nested includes
This commit is contained in:
Pilou 2017-07-20 16:26:13 +02:00 committed by Brian Coca
parent c19d25cf67
commit 556a1daa33
5 changed files with 80 additions and 0 deletions

View file

@ -304,6 +304,7 @@ class DataLoader:
search.append(unfrackpath(os.path.join(basedir, 'tasks', source), follow=False))
# try to create absolute path for loader basedir + templates/files/vars + filename
search.append(unfrackpath(os.path.join(basedir, source), follow=False))
search.append(unfrackpath(os.path.join(dirname, source), follow=False))
search.append(self.path_dwim(os.path.join(dirname, source)))