I have a requirement where in I need to create a monitoring task to monitor other task completions (all are part of the same playbook). Mainly the monitoring task has to take certain actions based on the progress made by the running tasks.
Essentially, I need a producer/consumer model where the producing tasks are the those who does some operations and notify the state changes to the consumer task to take certain decisions based on the progress.
Is there any out of the box support in Ansible to have a task running as a monitoring task for certain event notifications. If there is no straight way to do this, please revert if there is any alternate way to archive the same.
If you want to track certain events like “playbook start”, “play start”, “task start”, you can write and use a custom callback plugin. You can override the APIs like v2_playbook_on_task_start, v2_playbook_on_play_start etc.
You need to write business logic inside these methods. You can check existing callback plugins https://github.com/ansible-collections/community.general/tree/master/plugins/callback
Thank you for prompt reply. Since I am newbie to Ansible didn’t quite get why these callbacks are implemented in python. It would be great if you can send me an example, where we may register a callback that will be called by the play at desired state. Thank you inadvance.