Trigger task sequences in handlers

You can come close to this by doing something like the following:

  • name: Initiate notification here
    action: …
    notify: reinstall

Then write the hander:

handlers:

  • name: Handler task 1 : Notification handler starting point
    action: Whatever …
    register: reinstall_notification_received

  • name: Handler task 2
    action: Whatever
    when_changed: reinstall_notification_received

and so on and so forth. Handler tasks 1… n can be included in a handler task as well to shorten the parent playbook

Yes, annotating an include to indicate all contained actions should run as part of a handler would be nice. That’s in similar vein to a number of other desirables of attaching various stuff to includes. But the above has been sufficient for me as a workaround.

I just tested this:

  • hosts: localhost
    tasks:
  • command: echo t
    notify: do

handlers:

  • name: do
    command: echo h1
    notify: do1
  • name: do1
    command: echo h2

Which works as expected. So its eems to be possible to notiy a handler from a handler!

That surprises even me! :slight_smile:

Good deal!

This implementation of handlers is really elegant
By this I mean the multiple actions per handler, the ability to encapsulate in include files - i.e. multiple handlers per included file -, the ability to have both inline & included handler actions (seems obvious but has really nice uses), the “as written” order of handlers, and finally the re-notification to downstream handlers from within handlers.