IBM-Security / isam-ansible-roles

Ansible Custom Modules, Handlers and Tasks for ISAM. Requires "ibmsecurity" python package.
Apache License 2.0
24 stars 43 forks source link

Change order of commit handlers #187

Open tombosmansibm opened 4 years ago

tombosmansibm commented 4 years ago

to avoid that the appliance becomes unresponsive when both "commit" and "commit and restart" handlers are called. Now "commit and restart" is executed first.

See issue 172

Warkdev commented 3 years ago

Hello,

What's the reasonning of this PR ? The order of handlers in the YML file have no impact on how they are triggered, right ? They are only listed and can be used if you call them explicitly in a task somewhere else.

tombosmansibm commented 3 years ago

Handlers are executed in the order they’re listed. In situations where there are multiple handlers to be executed, you want the “Commit and restart” handler to be executed first (it also handles commit), this avoids ending up with an unresponsive appliance.

Warkdev commented 3 years ago

Wait, to be sure I get it, you mean that, if you describe in the handlers this:

- handler_A
- handler_B

And in your role/task file this:

- task: ..
  notify:
    - handler_B
    - handler_A

Handler B will be triggered after Handler A because in the handler file it's declared before ? This doesn't make sense to me, bit of weird, no ?

Cédric Servais

tombosmansibm commented 3 years ago

That is correct. But the real issue occurs when there's multiple handlers at different places (in different tasks). So for instance, you do multiple tasks, the first one you process notifies "commit and restart", the last one notifies "commit", the order of processing is based on the order in handlers.

tombosmansibm commented 3 years ago

Has nothing to do with the IBM Security code, btw, it is Ansible : https://docs.ansible.com/ansible/latest/user_guide/playbooks_handlers.html#controlling-when-handlers-run

Warkdev commented 3 years ago

Got it,

I wondered indeed :) Thank you !