pleroma.debian.social

Days since the fact that Ansible runs handlers at the end of the play and not at the end of the role that triggered them broke shit for me: 0️⃣

@zhenech
You can add a step in the role to force handlers to be processed at that point though...
replies
1
announces
0
likes
0

@wouter If that'd be my role, sure. The existing one doesn't tho, and my motivation to fix that is… it's complicated :)

@zhenech
Ah yes. The forever dilemma of "shall I spend time fixing someone else's bugs " πŸ˜‚

@zhenech I don't get why the handler aren't forced by at the end of the Role, logically that makes sense because the concept "encapsulated tasks in a Role" ends at the end of the Role.

And I have "meta: flush_handlers" at the end of every role ...

@ascherbaum @zhenech
I agree it's awful when things break, but the handler behavior is clearly documented:
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_handlers.html#controlling-when-handlers-run

@badnetmask @zhenech You know, documented != useful.

When I create a role, the intention is to wrap a certain piece of action/state in this role. Once the role execution is finished, there's nothing which prevents from running all notified handlers.

I get the argument about not running handlers multiple time, the counter argument is that a role which is executed later might find a situation where the service is not yet in the desired state.

@ascherbaum @zhenech
I personally prefer that I can choose when to run in the middle of a play, rather than not having that kind of control. But yeah, it's a matter of opinion at this point.

@badnetmask @zhenech You can control/force the "when" by using "meta: flush_handlers". Otherwise you don't really have any control, it runs at the end. That's it. Which is a problem when a later role or Play fails and no handler is run.

@ascherbaum @zhenech
Also, the handlers don't necessarily need to be defined in a role, and you can call role handlers from different roles or tasks, as long as they are in the same play. So it's an interesting behavior, but it has it's uses.

@ascherbaum @badnetmask
In my particular case it was:
- role from galaxy sets a service up (and schedules a restart of the service)
- my own role uses that happily
- service gets uselessly restarted by handler

Wouldn't have happened if
- you could cancel a handler (https://github.com/ansible/proposals/issues/105) as a service start is sufficient to "reload" config
- handlers would run at the end of the role

And yes, I can sprinkle "flush_handlers" everywhere (at the start and end of my role!)…

@zhenech *smirks in puppet dependency graph*

@towo not everything is bad about Puppet ;)
(as long as you don't try to export the graph as a dot file and view it)