# delegate\_to on included tasks?

**URL:** <https://forum.ansible.com/t/delegate-to-on-included-tasks/12513>\
**Category:** Ansible Project\
**Created:** [March 16, 2013, 1:23am UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513 "2013-03-16T01:23:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [March 16, 2013, 1:23am UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513/1 "2013-03-16T01:23:46Z")

</div>

I have a sequence of actions that I’ve encapsulated in a task, and that in some use-cases I need to run on a remote server.

Rather than duplicating the task, I’m going to try:

- put a delegate\_to: ${target} on each action in the task
- designate the target (localhost or remote\_server) on the include: as needed

and hope the above works. But it would be very nice to have a delegate\_to: on the include/task call.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 16, 2013, 1:29am UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513/2 "2013-03-16T01:29:03Z")

</div>

The concept of modifying task and playbook includes to auto-affix  
other properties is conceptually interesting.

Please file a feature request in github so we don't forget.

---

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [March 22, 2013, 12:43am UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513/3 "2013-03-22T00:43:50Z")

</div>

Same observation for tags

- include:   
tag:
- apache

---

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [March 22, 2013, 12:53am UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513/4 "2013-03-22T00:53:18Z")

</div>

Issue **#2480**

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 22, 2013, 2:18am UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513/5 "2013-03-22T02:18:06Z")

</div>

You can already do this, just not with that syntax. It works inline.

- include: some/file.yml tags=asdf,jkl,1234

Of course, both should be made to work.

---

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [April 1, 2013, 2:24pm UTC](https://forum.ansible.com/t/delegate-to-on-included-tasks/12513/6 "2013-04-01T14:24:17Z")

</div>

It does work very nicely, thanks.

The ability to do this is pretty much “make or break” to the usage of tags for us. Therefore, I’ll submit a doc improvement ticket for this so that the section on tags in the “Advanced Playbook” section specifically mentions this syntax. The only place I found a reference to this, post-facto, was in the examples, and I tend to go to those once I know a feature already exists.

I will also submit an enhancement to support the action-like syntax for tags in addition to the current behavior.
