mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
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:
parent
c19d25cf67
commit
556a1daa33
5 changed files with 80 additions and 0 deletions
|
@ -0,0 +1,9 @@
|
|||
# 'canary2' used instead of 'canary', otherwise a "recursive loop detected in
|
||||
# template string" occurs when both includes use static=yes
|
||||
- include: 'leaf_sublevel.yml canary2={{ canary }}'
|
||||
static: yes
|
||||
when: 'nested_include_static|bool' # value for 'static' can not be a variable, hence use 'when'
|
||||
|
||||
- include: 'leaf_sublevel.yml canary2={{ canary }}'
|
||||
static: no
|
||||
when: 'not nested_include_static|bool'
|
|
@ -0,0 +1,2 @@
|
|||
- set_fact:
|
||||
canary_fact: '{{ canary2 }}'
|
|
@ -80,3 +80,27 @@
|
|||
# both these via a handler include
|
||||
- included_handler
|
||||
- verify_handler
|
||||
|
||||
- include: branch_toplevel.yml canary=value1 nested_include_static=no
|
||||
static: no
|
||||
- assert:
|
||||
that:
|
||||
- 'canary_fact == "value1"'
|
||||
|
||||
- include: branch_toplevel.yml canary=value2 nested_include_static=yes
|
||||
static: no
|
||||
- assert:
|
||||
that:
|
||||
- 'canary_fact == "value2"'
|
||||
|
||||
- include: branch_toplevel.yml canary=value3 nested_include_static=no
|
||||
static: yes
|
||||
- assert:
|
||||
that:
|
||||
- 'canary_fact == "value3"'
|
||||
|
||||
- include: branch_toplevel.yml canary=value4 nested_include_static=yes
|
||||
static: yes
|
||||
- assert:
|
||||
that:
|
||||
- 'canary_fact == "value4"'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue