# Include with tasks

**URL:** <https://forum.ansible.com/t/include-with-tasks/11691>\
**Category:** Ansible Project\
**Created:** [July 17, 2012, 1:59pm UTC](https://forum.ansible.com/t/include-with-tasks/11691 "2012-07-17T13:59:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ansibleguest](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@ansibleguest](https://forum.ansible.com/u/ansibleguest)\
**Post date:** [July 17, 2012, 1:59pm UTC](https://forum.ansible.com/t/include-with-tasks/11691/1 "2012-07-17T13:59:28Z")

</div>

Inclusion works fine with vars\_files.  
But not with tasks when a variable is used within a filename ?

&nbsp;&nbsp;var:  
&nbsp;&nbsp;&nbsp;&nbsp;product: abc

&nbsp;&nbsp;vars\_files:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- vars/${product}.yml

&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;- include: tasks/${product}.yml

When the playbook is run you get - though the file is there:  
ERROR: file not found: tasks/${product}.yml

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 17, 2012, 2:06pm UTC](https://forum.ansible.com/t/include-with-tasks/11691/2 "2012-07-17T14:06:48Z")

</div>

> Inclusion works fine with vars\_files.  
> But not with tasks when a variable is used within a filename ?
> 
> var:  
> product: abc

It’s called “vars”.

This is the problem. I will make me a ticket to make it yell when invalid keywords are found in the play or task.

---

<div class="post-metadata">

**Author:** ![ansibleguest](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@ansibleguest](https://forum.ansible.com/u/ansibleguest)\
**Post date:** [July 17, 2012, 2:16pm UTC](https://forum.ansible.com/t/include-with-tasks/11691/3 "2012-07-17T14:16:40Z")

</div>

🙂

Sorry, its a typo in this post...  
in real it is vars: of course.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 17, 2012, 2:33pm UTC](https://forum.ansible.com/t/include-with-tasks/11691/4 "2012-07-17T14:33:38Z")

</div>

So in changing it to “vars” is the problem is still there?

---

<div class="post-metadata">

**Author:** ![ansibleguest](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@ansibleguest](https://forum.ansible.com/u/ansibleguest)\
**Post date:** [July 17, 2012, 2:39pm UTC](https://forum.ansible.com/t/include-with-tasks/11691/5 "2012-07-17T14:39:00Z")

</div>

Yes, problem still there.  
In vars\_files the $product is resolved,  
in tasks - include: tasks/${product}.yml it is not..

(devel checkout from today)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 17, 2012, 2:42pm UTC](https://forum.ansible.com/t/include-with-tasks/11691/6 "2012-07-17T14:42:18Z")

</div>

Oh, task includes, that narrows it down nicely, I was thinking of vars\_files.

I suspect you are the first to try this, it's just a missing template  
call around the path. Pretty simple.

Please make sure there is a ticket in github.

--Michael
