Tag inheritance: adding tags to multiple tasks
If you want to apply the same tag or tags to multiple tasks without adding atagsline to every task, you can define the tags at the level of your play or block, or when you add a role or import a file. Ansible applies the tags down the dependency chain to all child tasks. With roles and imports, Ansible appends the tags set by therolessection or import to any tags set on individual tasks or blocks within the role or imported file. This is called tag inheritance. Tag inheritance is convenient because you do not have to tag every task. However, the tags still apply to the tasks individually.
With plays, blocks, therolekeyword, and static imports, Ansible applies tag inheritance, adding the tags you define to every task inside the play, block, role, or imported file. However, tag inheritance doesnotapply to dynamic reuse withinclude_roleandinclude_tasks. With dynamic reuse (includes), the tags you define apply only to the include itself. If you need tag inheritance, use a static import. If you cannot use an import because the rest of your playbook uses includes, seeTag inheritance for includes: blocks and the apply keywordfor ways to work around this behavior.
You can apply tags to dynamic includes in a playbook. As with tags on an individual task, tags on aninclude_*task apply only to the include itself, not to any tasks within the included file or role. If you addmytagto a dynamic include, then run that playbook with--tagsmytag, Ansible runs the include itself, runs any tasks within the included file or role tagged withmytag, and skips any tasks within the included file or role without that tag. SeeSelectively running tagged tasks in reusable filesfor more details.