1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

* Update TaskInclude _raw_params with the expanded/templated path to file

* Add tests to validate host vars include paths
This commit is contained in:
Matt Martz 2018-04-26 14:25:02 -05:00 committed by GitHub
parent 2f5161628a
commit 4b01b92cfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 0 deletions

View file

@ -144,6 +144,8 @@ class IncludedFile:
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

View file

@ -0,0 +1,2 @@
- debug:
msg: one

View file

@ -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'

View file

@ -0,0 +1,2 @@
- debug:
msg: two

View file

@ -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 "$@"