Custom monitoring task in ansible

16 views
Skip to first unread message

Jagadeeshkumar Dittakavi

unread,
Jun 25, 2020, 5:13:11 AM6/25/20
to Ansible Project

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.



Abhijeet Kasurde

unread,
Jun 25, 2020, 5:30:43 AM6/25/20
to ansible...@googlegroups.com
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

Let me know if you have any questions.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ab674034-5eae-450d-b5ef-00c3e568a0d6o%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde

Jagadeeshkumar Dittakavi

unread,
Jun 25, 2020, 10:12:22 AM6/25/20
to Ansible Project
Hi Abhijeet,

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.

On Thursday, June 25, 2020 at 3:00:43 PM UTC+5:30, Abhijeet Kasurde wrote:
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

Let me know if you have any questions.


On Thu, Jun 25, 2020 at 2:43 PM Jagadeeshkumar Dittakavi <d.jagad...@gmail.com> wrote:

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.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.


--
Thanks,
Abhijeet Kasurde
Reply all
Reply to author
Forward
0 new messages