Using handlers and specifying the notify: reboot
Closed this issue · 2 comments
Since you are using handlers, the notify: reboot
is going to happen at the end of the play. Since the handler is only going to run once when the play has ended no need to call it multiple times.
if you need handlers to run before the end of the play, add a task to flush them using the meta module which executes ansible actions. More details: https://docs.ansible.com/ansible/latest/user_guide/playbooks_handlers.html#controlling-when-handlers-run
The meta: flush_handlers
task triggers any handlers that have been notified at that point in the play. Mind you since this is a reboot your gonna have to get your env to wait before proceeding if you need to flush prior to end of play.
This also applies for notify: restart container service
in https://github.com/hybrid-cloud-patterns/ansible-edge-gitops/blob/main/ansible/roles/container_lifecycle/tasks/main.yml
Thanks - I I think the reboot is OK where it is. In the original demo, the reboot was at the end of the play - I'm refactoring a bit to make it so the code is more idempotent. The mechanism for reboot as a handler has tested successfully so far.