Mixing roles and tasks
Plays that use roles are not limited to just roles. These plays can have tasks of their own, as well as two other blocks of tasks: pre_tasks and post_tasks. The order in which these are executed is not dependent upon which order these sections are listed in the play itself; instead, there is a strict order to block execution within a play. See Chapter 1, The System Architecture and Design of Ansible, for details on the playbook order of operations.
Handlers for a play are flushed at multiple points. If there is a pre_tasks block, handlers are flushed after all pre_tasks are executed. Then, the roles and tasks blocks are executed (roles first, then tasks, regardless of the order they are written in the playbook), after ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access