trigger or force a handler

I wonder if there is an elegant way to have a few tasks in a handler file, and execute them either triggered by other tasks or forced based on an input parameter.

Here is the scenario I have in mind…

  1. use ansible to sync a git repo, if that repo is updated, trigger a build handler
  2. execute something else, which causes an error

Since the handlers are executed in the end, if step 2) fails after step 1) is executed (which updates the repo), the build handler is never executed. The problem is that even if I fixed step 2), another Ansible run will not trigger the build - since the repo is considered unchanged for the second Ansible run.

I can probably flush the handlers right after step 1), but I’d prefer not do this. I wonder if I can pass in a parameter to ansible-play in the second run, to force the build handler. Or maybe you guys have better ideas? :slight_smile: Thanks…

This is a fairly common request.

The suggestion has been to implement something like a “–force-handlers” switch to Ansible playbook that runs all of them.

I think having to name the handlers might be too unfriendly.

–Michael