Enabling delegate_to on include_role via block

1,647 views
Skip to first unread message

Tim Diels

unread,
May 4, 2019, 3:10:00 AM5/4/19
to Ansible Project
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

Tim Diels

unread,
May 4, 2019, 3:12:20 AM5/4/19
to Ansible Project
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).

Tim Diels

unread,
May 4, 2019, 3:18:55 AM5/4/19
to Ansible Project
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.

Matt Martz

unread,
May 4, 2019, 7:40:35 PM5/4/19
to ansible...@googlegroups.com
This is expected. There is documentation to this effect at 

As of Ansible 2.7 see the "apply" argument to include_tasks and include_role to do what you want.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/06d1cc2e-e238-45f9-a670-d8c1109f490e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages