title | layout | canonical |
---|---|---|
PuppetDB 1.6 » API » v3 » Querying Facts |
default |
/puppetdb/latest/api/query/v3/facts.html |
Querying facts occurs via an HTTP request to the
/facts
REST endpoint.
This will return all facts matching the given query. Facts for deactivated nodes are not included in the response.
query
: Optional. A JSON array containing the query in prefix notation. If not provided, all results will be returned.
"name"
: matches facts of the given name"value"
: matches facts with the given value"certname"
: matches facts for the given node
Get the operatingsystem fact for all nodes:
curl -X GET http://puppetdb:8080/v3/facts --data-urlencode 'query=["=", "name", "operatingsystem"]'
[{"certname": "a.example.com", "name": "operatingsystem", "value": "Debian"},
{"certname": "b.example.com", "name": "operatingsystem", "value": "RedHat"},
{"certname": "c.example.com", "name": "operatingsystem", "value": "Darwin"},
Get all facts for a single node:
curl -X GET http://puppetdb:8080/v3/facts --data-urlencode 'query=["=", "certname", "a.example.com"]'
[{"certname": "a.example.com", "name": "operatingsystem", "value": "Debian"},
{"certname": "a.example.com", "name": "ipaddress", "value": "192.168.1.105"},
{"certname": "a.example.com", "name": "uptime_days", "value": "26 days"}]
This will return all facts for all nodes with the indicated name.
query
: Optional. A JSON array containing the query in prefix notation. The syntax and semantics are identical to thequery
parameter for the/facts
route, mentioned above. When supplied, the query is assumed to supply additional criteria that can be used to return a subset of the information normally returned by this route.
curl -X GET http://puppetdb:8080/v3/facts/operatingsystem
[{"certname": "a.example.com", "name": "operatingsystem", "value": "Debian"},
{"certname": "b.example.com", "name": "operatingsystem", "value": "Redhat"},
{"certname": "c.example.com", "name": "operatingsystem", "value": "Ubuntu"}]
This will return all facts for all nodes with the indicated name and value.
query
: Optional. A JSON array containing the query in prefix notation. The syntax and semantics are identical to thequery
parameter for the/facts
route, mentioned above. When supplied, the query is assumed to supply additional criteria that can be used to return a subset of the information normally returned by this route.
curl -X GET http://puppetdb:8080/v3/facts/operatingsystem/Debian
[{"certname": "a.example.com", "name": "operatingsystem", "value": "Debian"},
{"certname": "b.example.com", "name": "operatingsystem", "value": "Debian}]
This query endpoint supports paged results via the common PuppetDB paging query parameters. For more information, please see the documentation on paging.
Successful responses will be in application/json
. Errors will be returned as
non-JSON strings.
The result will be a JSON array, with one entry per fact. Each entry is of the form:
{
"certname": <node name>,
"name": <fact name>,
"value": <fact value>
}
If no facts are known for the supplied node, an HTTP 404 is returned.