delegate_to on included tasks?

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.

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.

Same observation for tags

  • include:
    tag:
  • apache

Issue #2480

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.

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.