Including roles: dynamic reuse
You can reuse roles dynamically anywhere in thetaskssection of a play usinginclude_role. While roles added in arolessection run before any other tasks in a play, included roles run in the order they are defined. If there are other tasks before aninclude_roletask, the other tasks will run first.
To include a role:
You can pass other keywords, including variables and tags, when including roles:
When you add atagto aninclude_roletask, Ansible applies the tagonlyto the include itself. This means you can pass--tagsto run only selected tasks from the role, if those tasks themselves have the same tag as the include statement. SeeSelectively running tagged tasks in reusable filesfor details.
You can conditionally include a role: