In which order do notified handlers run?
In the order they are written in the handlers: section, not the order of the notify list and not the order in which tasks notified them.
* The handlers section sets the order; notify only says which ones run. *
Notification only marks a handler as "needs to run". When the handlers are flushed, Ansible walks through the handlers: section from top to bottom and runs each marked one.
So if a task has notify: [restart apache, restart mysql] but the section defines restart mysql first, MariaDB is restarted before Apache. If one service must come up before another (the database before the web application that connects to it), put the handlers in that order in the section. Rearranging notify lists changes nothing.
Go deeper:
Notifying handlers (official docs) โ "executed in the order they are defined in the handlers section".