5

(Related to Callbacks or hooks, and reusable series of tasks, in Ansible roles):

Does Ansible provide a way to flush notifications for just one handler?

Like meta: flush_handlers, but for a single named handler?

Or a way to fire a handler as soon as it's notified?

7
  • 2
    How about converting the handler to a task that uses when to run conditionally? Apr 28, 2015 at 12:07
  • What are you actually trying to achieve?
    – xddsg
    Jun 25, 2015 at 15:37
  • @xddsg A role that I can attach event listeners to, so that at certain stages of its tasks I can let other roles do work. Right now I have to use hacks with include files, or I have to split this role up into tons of tiny little roles so I can have other tiny little roles run in between them. For example, I want to be able to say "I am about to restart PostgreSQL, so make any configuration changes you need to now" or "I have just restarted PostgreSQL, so run any CREATE EXTENSION commands you need to now" as part of a postgres role that I apply extension roles for PostGIS etc to. Jun 26, 2015 at 1:15
  • @CraigRinger in that case, when: sounds like a fair option, or you'll just have to accept the eventual consistency that normal and flushed notifiers provides. You're trying to do a bunch of actions in a really specific order rather than have the machines arrive a particular state just at the end. An actual python or bash script might actually be better for you.
    – xddsg
    Jun 26, 2015 at 15:37
  • Well, that's the thing: it doesn't have to be in a really specific order, I just need barriers, points where things sync up and then work proceeds. This can be done by writing everything in a series of playbooks with separate roles, or using piles of tags to re-run the same playbook as different stages, but that's just plain ugly. I'm looking for a way to use Ansible's configuration management, which in every other way makes things a lot easier, rather than reinvent the whole thing just because of one extra need. Jun 26, 2015 at 15:53

0

You must log in to answer this question.

Browse other questions tagged .