How Monitoring Ansible Playbook Events (event handling)

Hello all,

I would like to monitor my Ansible playbooks with Icinga2.

The background is that the playbooks are configured at night and I would like to get a notification in the monitoring when an error occurs. When a playbook fails the error is triggered in ansible.log.

Does anyone of you have experience or ideas how I can best monitor my Ansible playbooks?

Best wishes :smiley:

You could implement a passive check in icinga.
the service uses the dummy checkcommand which is always ok.
if your ansible playbook runs at night it should send as part of the playbook a result to icinga for the passive check created earlier. use process-check-result via api to get the information into icinga

2 Likes

Use a log check like logfile from Linuxfabrik and use pattern failed=[1-9]. I can recommend the one form Linuxfabrik because if you setup the API user you don’t need to rotate the log as acknowledging the service will tell the check to ignore the old problems and only check for new ones.

2 Likes

A Ansible Icinga Callback would also be a interesting option.

https://docs.ansible.com/ansible/latest/plugins/callback.html#example-callback-plugins

1 Like

Thanks for your support guys, you have helped me a lot !!!