Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TaskInclude _raw_params with the expanded/templated path to file #39365

Merged
merged 2 commits into from Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ansible/playbook/included_file.py
Expand Up @@ -144,6 +144,8 @@ def process_include_results(results, iterator, loader, variable_manager):
include_file = loader.path_dwim(include_result['include'])

include_file = templar.template(include_file)
# Update the task args to reflect the expanded/templated path
original_task.args['_raw_params'] = include_file
inc_file = IncludedFile(include_file, include_variables, original_task)
else:
# template the included role's name here
Expand Down
@@ -0,0 +1,2 @@
- debug:
msg: one
@@ -0,0 +1,14 @@
- hosts: testhost:testhost2
tasks:
- set_fact:
include_me: one
when: inventory_hostname == ansible_play_hosts[0]

- set_fact:
include_me: two
when: inventory_hostname == ansible_play_hosts[1]

- debug:
var: include_me

- include_tasks: '{{ include_me }}/include_me.yml'
@@ -0,0 +1,2 @@
- debug:
msg: two
4 changes: 4 additions & 0 deletions test/integration/targets/include_import/runme.sh
Expand Up @@ -63,3 +63,7 @@ ANSIBLE_STRATEGY='linear' ansible-playbook test_grandparent_inheritance.yml -i .
# undefined_var
ANSIBLE_STRATEGY='linear' ansible-playbook undefined_var/playbook.yml -i ../../inventory "$@"
ANSIBLE_STRATEGY='free' ansible-playbook undefined_var/playbook.yml -i ../../inventory "$@"

# Include path inheritance using host var for include file path
ANSIBLE_STRATEGY='linear' ansible-playbook include_path_inheritance/playbook.yml -i ../../inventory "$@"
ANSIBLE_STRATEGY='free' ansible-playbook include_path_inheritance/playbook.yml -i ../../inventory "$@"