Icinga/ansible-collection-icinga

Add functionality to place agent in downtime

Opened this issue · 6 comments

It would be great to add a feature where a host with all its services or just one service gets placed into downtime for X amount minutes.
This would be great for if the server is not ready yet with all its services while its being setup causing alerts / pages.
Also great for patching or other events that ansible will do with certain services that are monitored like upgrading said service.

Hi do you mean to set downtimes via the API for hosts and services?

Hi,
Yes normally you could do something like this:

curl -k  -u user:password -H 'Accept: application/json' \
 -X POST 'https://icinga.internal:5665/v1/actions/schedule-downtime' \
 -d '{ "type": "Service", "filter": "host.name==\"server.internal\" && service.name==\"ping4\"", "start_time": 1592856490, "end_time": 1592866490, "all_services": true, "author": "ansible", "comment": "Patching!", "pretty": true }'

Which works in ansible if you put all kinds of variables there but is not very elegant!

It would be great if there were:

- name: "Place agent into downtime"
  icinga2_downtime:
     host: {{ inventory_hostname }}
     start: {{ some form of date and time }}
     end: {{ some form of date and time }}
     all_service: True/False 
     service: ping4
     comment: "Patching"
     type: flexible/fixed
     child_hosts: None/triggered/non-triggered 
  when: XX
  with_items: XX

I've done something likes this in the past, maybe I can provide an additional module to handle downtimes. But I think it needs some rewriting. If can excerpt the module and provide it in an separate repository before adding it to the collection.

https://github.com/mkayontour/icinga2_ansible_collection/blob/master/plugins/modules/icinga2_downtimes.py

Thanks for that link, Looks like you have done quite a bit!

I spot a few todo's with the same subject: Rewrite filter and make second request for single services or multiple
Anything else you had an idea of rewriting ?

I guess a branch in this repo will do for the dev. of this module ?

Thanks, I need to get myself updated on this module. But I remember that I had problems with removing downtimes, because the API call always removes all downtimes. I'll put this in a branch.

Ah that is a good feature to be aware of, Looking forward to a branch to colab on!