I am looking for a way to set downtime on a list of hosts via ansible.
I did some web search and only found how to set downtime on a single host using an url like
I feel it’s a bit much calling this URL for every single host in the list. Is there a way to form an url that handles multiple hosts at once like with the host_regex parameter instead of just “host”? Or is there a way to do this with a single REST API call?
So far we had no group that could not be predefined. But if the groups are only known at runtime and cannot be meaningfully predefined, such as “all Linux servers at location x” or "all servers with tag/label me2, then you probably have no other choice than to call the API for each host individually (You could parallelise the API calls to a certain extent).
Please keep in mind that the Web API no longer exists as of 2.2. With the host_by_query option in the REST-API it should be possible to pass an adhoc group of hosts:
A query expression of the Livestatus ‘hosts’ table in nested dictionary form. If you want to use multiple expressions, nest them with the AND/OR operators.