I'm a bit confused how variables are defined when using `include_role`.  A 
basic example follows.

*/play.yml*
- hosts: localhost
  roles:
    - one



*/roles/one/tasks/main.yml*
---
- name: do a thing with another role
  include_role:
    name: two
  vars:
   passed_variable:
     - stuff: "{{ lookup('template', 'role_one_template.j2') }}"


*/roles/one/templates/role_one_template_file.j2*
bla bla bla bla 
random bit of stuff
does not matter what 


*/roles/two/tasks/main.yml*
---
- debug:
    var: passed_variable


My expectation is that role "one" will pull the template and pass the 
*results* of that lookup to role "two".  However, when running the play, I 
get first a warning, and then an error.  It *seems* as if the template 
lookup occurs in role "two".  So, what exactly is going on, and how do I 
fix it?


looking for "role_one_template.j2" at 
> "/roles/two/templates/role_one_template.j2"
> looking for "role_one_template.j2" at "/roles/two/role_one_template.j2"
> looking for "role_one_template.j2" at "/templates/role_one_template.j2"
> looking for "role_one_template.j2" at "/role_one_template.j2"
>  [WARNING]: Unable to find 'role_one_template.j2' in expected paths (use 
> -vvvvv to see paths)

...
> ...

ERROR! An unhandled exception occurred while templating '{u'stuff': [{{ 
> lookup(\'template\', \'role_one_template.j2\') }}]}'.
> Error was a <class 'ansible.errors.AnsibleError'>, original message: An 
> unhandled exception occurred while running the lookup plugin 'template'.
> Error was a <class 'ansible.errors.AnsibleError'>, original message: the 
> template file role_one_template.j2 could not be found for the lookup




-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/16d95836-e93b-4e98-828d-9b4f176a0047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to