Icinga2 API - get specific hosts from templates

659 views Asked by At

How can i set my filters to get only the hosts from a template, which have a custom variable set to true?

With this curl, im getting all hosts in the template but not the ones, which have set the custom_var true

    curl -k -s -u $apiuser:$apipassword -H 'Accept: application/json' -X         
    POST -H 'X-HTTP-Method-Override: GET' https://$url:$port/v1/objects
    /hosts -d '{ "filter": "\"template\" in host.templates",
    "filter_vars": { "custom_var": true } } ' | jq '.'

Any ideas on how can i get the specific hosts?

1

There are 1 answers

0
baumi On

Finally got i working. I edited my filter as follows:

   -d '{ "filter": "\"template\" in host.templates && host.vars.custom == true" } ''' | jq '.'