Notify without using handlers?

Hi,

In my cookbook, I have a lot of notify statements, e.g.

notify:

  • restart apache

notify:

  • restart mysql

handlers:

  • name: restart apache
    service: name=httpd state=restarted

…many handlers…

And all these need to be specified in handlers, sound not elegant, right?
are there any better way to do it? e.g. notify to restart directly?

You can always have the “service: name=httpd state=restarted” anywhere in your play, as long as isn’t required that it be run at the end of the play. There is no requirement that it has to be specified in a handler.