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?
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.
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.
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.
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?