# include\_tasks vs include

**URL:** <https://forum.ansible.com/t/include-tasks-vs-include/28804>\
**Category:** Ansible Project\
**Created:** [October 17, 2018, 9:23am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804 "2018-10-17T09:23:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Joyce](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ben_joyce/32/5078_2.png) [@Ben\_Joyce](https://forum.ansible.com/u/Ben_Joyce)\
**Post date:** [October 17, 2018, 9:23am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/1 "2018-10-17T09:23:46Z")

</div>

Hi. Has include\_tasks been deprecated? I have a playbook that used include\_tasks fine up until recently.

ansible-playbook --version reports 2.7.0

Unfortunately I can’t be sure of what the previous version was, if it was indeed different.

Either way, include\_tasks no longer works for me. I get this error:

ERROR! Invalid options for include\_tasks: item

The error appears to have been in ‘/vagrant/workspace/pcf-automation-infrastructure/ansible/bosh/prep.yml’: line 53, column 7, but may  
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- include\_tasks: …/roles/common/tasks/download.yml item={{item}}  
^ here  
We could be wrong, but this one looks like it might be an issue with  
missing quotes. Always quote template expression brackets when they  
start a value. For instance:

with\_items:

- {{ foo }}

Should be written as:

with\_items:

- “{{ foo }}”

If I use include instead it works.

Any ideas?

Cheers,

Ben

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 17, 2018, 9:37am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/2 "2018-10-17T09:37:26Z")

</div>

> Hi. Has include\_tasks been deprecated? I have a playbook that used  
> include\_tasks fine up until recently.
> 
> ansible-playbook --version reports 2.7.0
> 
> Unfortunately I can't be sure of what the previous version was, if it was  
> indeed different.
> 
> Either way, include\_tasks no longer works for me. I get this error:
> 
> ERROR! Invalid options for include\_tasks: item

\<snip /\>

> Any ideas?

The documentation say that include\_tasks is preview so it's subjected to change  
[https://docs.ansible.com/ansible/2.7/modules/include\_tasks\_module.html#status](https://docs.ansible.com/ansible/2.7/modules/include_tasks_module.html#status)

So when you upgrade you need to check the documentation again for those module and read the porting guide.  
[https://docs.ansible.com/ansible/devel/porting\_guides/porting\_guide\_2.7.html#include-tasks-import-tasks-inline-variables](https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_2.7.html#include-tasks-import-tasks-inline-variables)

---

<div class="post-metadata">

**Author:** ![Ben\_Joyce](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ben_joyce/32/5078_2.png) [@Ben\_Joyce](https://forum.ansible.com/u/Ben_Joyce)\
**Post date:** [October 17, 2018, 10:08am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/3 "2018-10-17T10:08:04Z")

</div>

Thanks Kia. Really appreciate your quick and detailed response.

Regards,

Ben

---

<div class="post-metadata">

**Author:** ![Eugene\_Wong](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Eugene\_Wong](https://forum.ansible.com/u/Eugene_Wong)\
**Post date:** [October 18, 2018, 4:01am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/4 "2018-10-18T04:01:40Z")

</div>

Hi Ben,

From the error message it could seem like double quotes are required:

item=“{{item}}”

Eugene

---

<div class="post-metadata">

**Author:** ![Ben\_Joyce](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ben_joyce/32/5078_2.png) [@Ben\_Joyce](https://forum.ansible.com/u/Ben_Joyce)\
**Post date:** [October 19, 2018, 9:41am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/5 "2018-10-19T09:41:51Z")

</div>

Hi Eugene. I did try that suggestion but unfortunately it did not make any difference.

Regards,

Ben

---

<div class="post-metadata">

**Author:** ![Oriol\_Tauleria](https://avatars.discourse-cdn.com/v4/letter/o/58f4c7/32.png) [@Oriol\_Tauleria](https://forum.ansible.com/u/Oriol_Tauleria)\
**Post date:** [October 19, 2018, 10:09am UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/6 "2018-10-19T10:09:04Z")

</div>

Hello Ben,  
could you update the entire playbook?  
The problem could be in the items list, have you tried to add quotes to each item?

El dv., 19 oct. 2018 11.43, Ben Joyce \<[ben.joyce@gmail.com](mailto:ben.joyce@gmail.com)\> va escriure:

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 19, 2018, 2:39pm UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/7 "2018-10-19T14:39:39Z")

</div>

FYI item="{{item}}" is really a noop

---

<div class="post-metadata">

**Author:** ![Ben\_Joyce](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ben_joyce/32/5078_2.png) [@Ben\_Joyce](https://forum.ansible.com/u/Ben_Joyce)\
**Post date:** [October 19, 2018, 5:06pm UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/8 "2018-10-19T17:06:01Z")

</div>

Just googled “noop” - not quite sure what you mean, Brian… can you elaborate? 🙂

---

<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 19, 2018, 5:14pm UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/9 "2018-10-19T17:14:46Z")

</div>

noop == no-op == No Operation

You are setting a variable named `item` to the variable named `item`. That is unnecessary, and does nothing for you. Simply omitting `item={{item}}` will do the same thing.

---

<div class="post-metadata">

**Author:** ![Ben\_Joyce](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ben_joyce/32/5078_2.png) [@Ben\_Joyce](https://forum.ansible.com/u/Ben_Joyce)\
**Post date:** [October 19, 2018, 9:08pm UTC](https://forum.ansible.com/t/include-tasks-vs-include/28804/10 "2018-10-19T21:08:14Z")

</div>

Thanks Matt, appreciated.
