# include\_role with passed variable defined by template fails

**URL:** <https://forum.ansible.com/t/include-role-with-passed-variable-defined-by-template-fails/28794>\
**Category:** Ansible Project\
**Created:** [October 16, 2018, 4:06am UTC](https://forum.ansible.com/t/include-role-with-passed-variable-defined-by-template-fails/28794 "2018-10-16T04:06:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dmitriy\_Panteleyev](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@Dmitriy\_Panteleyev](https://forum.ansible.com/u/Dmitriy_Panteleyev)\
**Post date:** [October 16, 2018, 4:06am UTC](https://forum.ansible.com/t/include-role-with-passed-variable-defined-by-template-fails/28794/1 "2018-10-16T04:06:00Z")

</div>

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**  
`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [October 16, 2018, 2:47pm UTC](https://forum.ansible.com/t/include-role-with-passed-variable-defined-by-template-fails/28794/2 "2018-10-16T14:47:32Z")

</div>

The template does not exist. You are using the wrong template file in your lookup call:

```auto
- stuff: "{{ lookup('template', 'role_one_template.j2') }}"

```

However, you have indicated the file is actually named: /roles/one/templates/role\_one\_template\_file.j2

---

<div class="post-metadata">

**Author:** ![Dmitriy\_Panteleyev](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@Dmitriy\_Panteleyev](https://forum.ansible.com/u/Dmitriy_Panteleyev)\
**Post date:** [October 16, 2018, 4:44pm UTC](https://forum.ansible.com/t/include-role-with-passed-variable-defined-by-template-fails/28794/3 "2018-10-16T16:44:26Z")

</div>

Sorry, that was just a typo in my example. The filenames all match.

---

<div class="post-metadata">

**Author:** ![Dmitriy\_Panteleyev](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@Dmitriy\_Panteleyev](https://forum.ansible.com/u/Dmitriy_Panteleyev)\
**Post date:** [October 18, 2018, 7:21pm UTC](https://forum.ansible.com/t/include-role-with-passed-variable-defined-by-template-fails/28794/4 "2018-10-18T19:21:24Z")

</div>

Finally tracked the issue down to my misunderstanding of how lookup() works.

Answer here: [https://groups.google.com/forum/#!topic/ansible-project/McPi-i-90yU](https://groups.google.com/forum/#!topic/ansible-project/McPi-i-90yU)
