Trigger `notify` events at a given point.

Hi community,

thanks again for the great project :slight_smile:

I was thinking of my usage of notify and handlers. I don’t use them much and I find myself rewriting the pattern by inserting some “restart” actions in the middle of my tasks. And then, I also write some “changes detectors” to run those restarts conditionally… kind of re-doing what the notify / handlers does.

Why am I not using the notify / handlers, then ? It’s because I can’t control where and when it’s going to be handled… What would fit my use case, would be to have something like:

  • name: Trigger restarts
    action: apply_notifies

or

  • apply_notifies: $item
    with_items:
  • restart this service
  • restart that service

and then, if it was notified only… it would run that handler.

Would that be complex to build, or useful to any ?

Thanks!

Alexandre

There have been many discussions on notify/handlers, some of them overlap with what you are asking for here, I’m not sure where the state of them are (check this list and github issues).

I currently lack the time, but would like to implement ‘immediate’, ‘on error’, ‘if x fail/succeed’, notify: [list] and other options, but it is hard to design in a way that fits well in ansible.

In general I don't want to see the handler logic greatly expanded, and
I don't like the proposed syntax.

One way you can deal with this is to use "ignore_errors: True" and
then deal with the error condition in an 'only_if' or 'when_boolean'
statement right after it.