Run handlers after a role

Hi,

I' m wondering if it would be an idea to add the option to run
handlers from a role after each role when running several roles after
each other

Today we had the following issue :

We have a role for iptables which uses a template with variables to
add ports. After that role we configure a mongodb instance

roles:¬
  - rh-proxy¬
  - iptables¬
  - mongodb¬

We had an error in the mongodb role resulting in the handlers not
being executed and therefore not restarting iptables to open up the
necessary ports.

maybe something like this might be an option :

roles:¬
- rh-proxy¬
- { role: iptables, run_handlers=1}¬
- mongodb¬

Just an idea.

V.

I seem to remember there was some discussion on some ‘flush handlers’ option.

I guess the same problem could happen, when having multiple playbooks ran sequantially, and one of the latter ones depending on a handler action.
(handlers also run at the end of the whole playbooks, after all plays ran)

There are several points at which handlers run. They run between plays, and they run immediately after “pre_tasks” and “roles/tasks” (together) and after “post_tasks”.

Pre and post tasks are primarily for monitoring and load balancer integration.

Should you want to force handlers to run, you can put in a task like so:

tasks:

  • meta: flush_handlers

anywhere you like.

Of course, “when: foo.changed” with register can often be more clear, if you need something to run immediately.

Small request Serge…

When you don’t know how something works, please ask how it works (or try it), rather than speculate and call it a problem. It would help make the list more positive.

Handlers automatically run between plays, every single time, so this is a non-issue.

Between each play in a multiple-play playbook, handlers always are activated.

Michael,

Thanks. Very helpful

V.