# include\_tasks with tags, regression of feature?

**URL:** <https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519>\
**Category:** Ansible Project\
**Created:** [January 19, 2018, 3:58pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519 "2018-01-19T15:58:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Klebolt](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Klebolt](https://forum.ansible.com/u/Mike_Klebolt)\
**Post date:** [January 19, 2018, 3:58pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519/1 "2018-01-19T15:58:05Z")

</div>

I’m trying to dynamically include tasks along with using tags. The issue I’m running into is that yes, its including the tasks file, but its not executing any of the tasks within that file. After reading the Creating Reusable Playbooks guide, it appears this is by design for include\_tasks. My question is why? I’m now left having to add a tag to each individual task within the dynamically included tasks file. This seems less than ideal. Is there a better way I should be going about this?

Example:

playbook.yml

`

---

<div class="post-metadata">

**Author:** ![Mike\_Klebolt](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Klebolt](https://forum.ansible.com/u/Mike_Klebolt)\
**Post date:** [January 19, 2018, 4:03pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519/2 "2018-01-19T16:03:22Z")

</div>

I’ve also tried wrapping all the tasks in the dynamically included file in a block and adding a tag to the block. This achieves what I’m trying to accomplish but doesn’t feel like the proper approach.

---

<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:** [January 19, 2018, 4:17pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519/3 "2018-01-19T16:17:25Z")

</div>

The explanation listed at [https://github.com/ansible/ansible/issues/35065#issuecomment-358998670](https://github.com/ansible/ansible/issues/35065#issuecomment-358998670) should hopefully answer your questions.

If you want an attribute to be inherited on the tasks, you should use `import_tasks` as opposed to `include_tasks`. Attributes on `include_tasks` should apply to the include only, whereas attributes on `import_tasks` will be inherited by the imported tasks.

---

<div class="post-metadata">

**Author:** ![Mike\_Klebolt](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Klebolt](https://forum.ansible.com/u/Mike_Klebolt)\
**Post date:** [January 19, 2018, 4:53pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519/4 "2018-01-19T16:53:43Z")

</div>

I won’t be able to use 2.5 since import\_tasks with a dynamically assigned variable with fail. Is there a way around this?

`

---

<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:** [January 19, 2018, 4:59pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519/5 "2018-01-19T16:59:21Z")

</div>

As you have discovered, you will need to use the `block` method if you want to “easily” apply a tag or set of tags to a group of tasks without tagging each one individually.

Attributes applied to a dynamic include (include\_\*) apply to the include and not to the tasks within. This is the primary purpose of dynamic includes. To allow the attributes applied to the include to affect whether or not the include is processed.

---

<div class="post-metadata">

**Author:** ![Mike\_Klebolt](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Klebolt](https://forum.ansible.com/u/Mike_Klebolt)\
**Post date:** [January 22, 2018, 2:32pm UTC](https://forum.ansible.com/t/include-tasks-with-tags-regression-of-feature/26519/6 "2018-01-22T14:32:57Z")

</div>

Thanks Matt. I was able to get everything functioning using the `block` method. Do you know if this will be revisited in a future release because I grew to like the include functionality prior to ebf971f?
