# Event handler using ansible

**URL:** <https://forum.ansible.com/t/event-handler-using-ansible/29415>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [January 10, 2019, 4:47pm UTC](https://forum.ansible.com/t/event-handler-using-ansible/29415 "2019-01-10T16:47:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sathya\_Narayanan](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Sathya\_Narayanan](https://forum.ansible.com/u/Sathya_Narayanan)\
**Post date:** [January 10, 2019, 4:47pm UTC](https://forum.ansible.com/t/event-handler-using-ansible/29415/1 "2019-01-10T16:47:54Z")

</div>

Hi All,

I know, I have ask this question before, but to my surprise I don’t find any better documentation on internet which can say how I can use mandible as a EDI tool (event driven infra).

We have nagios in our environment and use awx for automation. I already have more to 50 templates and workflow for automating some basic tasks. Now I need to make ansible to listen to nagios events and based on the events ansible should trigger jobs.

1. I am not sure if my ask is possible.
2. if its possible, can some one guide me with some good documentation

Thanks  
Sathya.R

---

<div class="post-metadata">

**Author:** ![dch](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dch/32/7132_2.png) [@dch](https://forum.ansible.com/u/dch)\
**Post date:** [January 19, 2019, 5:56pm UTC](https://forum.ansible.com/t/event-handler-using-ansible/29415/2 "2019-01-19T17:56:43Z")

</div>

Hi Sathya

yes this is possible. You can use ansible-runner [1] to do this, but you'll need  
to do some work in python to deal with getting events out from nagios.

I am using this setup with rabbitmq as an event source and it works nicely.

[1]: [https://ansible-runner.readthedocs.io/en/latest/python\_interface.html#usage-examples](https://ansible-runner.readthedocs.io/en/latest/python_interface.html#usage-examples)

The general approach is that you have a "main" python function that listens  
to your event stream from nagios, and if you see something interesting, then  
kick off an ansible runner.

Concurrency is not python's strong point so bear in mind what might happen  
if you have multiple matching events arriving in a short space of time.

A+  
Dave

---

<div class="post-metadata">

**Author:** ![Sathya\_Narayanan](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Sathya\_Narayanan](https://forum.ansible.com/u/Sathya_Narayanan)\
**Post date:** [January 20, 2019, 12:33pm UTC](https://forum.ansible.com/t/event-handler-using-ansible/29415/3 "2019-01-20T12:33:24Z")

</div>

Thanks dave, I will take a look it ansible-runner.
