4

(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?

Craig Ringer
  • 10,553
  • 9
  • 38
  • 59
  • 2
    How about converting the handler to a task that uses `when` to run conditionally? – Antonis Christofides Apr 28 '15 at 12:07
  • What are you actually trying to achieve? – xddsg Jun 25 '15 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. – Craig Ringer Jun 26 '15 at 01: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 '15 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. – Craig Ringer Jun 26 '15 at 15:53
  • I generally like the way Ansible does stuff in order, rather than Puppet's being rather too eager to re-order stuff in unpredictable ways. It's just a bit *too* inflexible about it. – Craig Ringer Jun 26 '15 at 15:56
  • @CraigRinger potential relevant https://groups.google.com/forum/#!topic/ansible-project/GB6xSr0WlZA see the comment about `pre_tasks` and `post_tasks` – xddsg Jun 26 '15 at 16:40

0 Answers0