We make some use of the Global Parameters in Foreman, and I need to list all hosts, which have the Global Parameter foo
set to "bar
".
Can I do that with the REST API or via some other method? Going through the list of API-calls, I do not find anything applicable -- is there hope?
Alternatively, I'm thinking of creating a special Puppet-class, which will do nothing but restate the global parameters as its own variables. By making it an exported resource, I may be able to collect the data from all hosts... Seems nasty, however -- is there a better way?
You want
GET /api/v2/hosts
(API doc) to retrieve a list of hosts, then add thesearch
parameter to filter the result.Use
search=params.foo=bar
to filter for thefoo
parameter. You can find other search strings through the UI search autocomplete (it's exactly the same syntax) and more information's in Foreman manual: Searching.So, the full URL to query would be something like: