# Enabling delegate\_to on include\_role via block

**URL:** <https://forum.ansible.com/t/enabling-delegate-to-on-include-role-via-block/30266>\
**Category:** Ansible Project\
**Created:** [May 4, 2019, 7:10am UTC](https://forum.ansible.com/t/enabling-delegate-to-on-include-role-via-block/30266 "2019-05-04T07:10:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Diels](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@Tim\_Diels](https://forum.ansible.com/u/Tim_Diels)\
**Post date:** [May 4, 2019, 7:10am UTC](https://forum.ansible.com/t/enabling-delegate-to-on-include-role-via-block/30266/1 "2019-05-04T07:10:00Z")

</div>

Hi,

I noticed that while:

- include\_role:  
name: myrole  
delegate\_to: somehost

will not delegate the included role, this will:

- block:
- include\_role:  
name: myrole  
delegate\_to: somehost

Is this by design, i.e. I may rely on it, or is this a fluke that may get ‘fixed’ in future releases?

Best regards,

Tim

---

<div class="post-metadata">

**Author:** ![Tim\_Diels](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@Tim\_Diels](https://forum.ansible.com/u/Tim_Diels)\
**Post date:** [May 4, 2019, 7:12am UTC](https://forum.ansible.com/t/enabling-delegate-to-on-include-role-via-block/30266/2 "2019-05-04T07:12:20Z")

</div>

By delegating the included role I mean delegating the tasks inside the role and any more included/imported by that role or even tasks of roles the role depends on (I tested this on ansible 2.7.10).

---

<div class="post-metadata">

**Author:** ![Tim\_Diels](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@Tim\_Diels](https://forum.ansible.com/u/Tim_Diels)\
**Post date:** [May 4, 2019, 7:18am UTC](https://forum.ansible.com/t/enabling-delegate-to-on-include-role-via-block/30266/3 "2019-05-04T07:18:55Z")

</div>

Analog for tags it turns out that:

- block:
- include\_role:  
name: myrole  
tags: mytag

will apply the tag to tasks inside the role, its dependencies, roles that it includes/imports. Is this too a feature?

The block trick also works for include\_tasks and import\_tasks for both setting tags and delegate\_to.

---

<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:** [May 4, 2019, 11:38pm UTC](https://forum.ansible.com/t/enabling-delegate-to-on-include-role-via-block/30266/4 "2019-05-04T23:38:56Z")

</div>

This is expected. There is documentation to this effect at  
[https://docs.ansible.com/ansible/latest/porting\_guides/porting\_guide\_2.5.html#dynamic-includes-and-attribute-inheritance](https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.5.html#dynamic-includes-and-attribute-inheritance)

As of Ansible 2.7 see the “apply” argument to include\_tasks and include\_role to do what you want.
