Skip to content

Latest commit

 

History

History
118 lines (77 loc) · 3.63 KB

facts.markdown

File metadata and controls

118 lines (77 loc) · 3.63 KB
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.

Routes

GET /v3/facts

This will return all facts matching the given query. Facts for deactivated nodes are not included in the response.

URL Parameters

  • query: Optional. A JSON array containing the query in prefix notation. If not provided, all results will be returned.

Available Fields

  • "name": matches facts of the given name
  • "value": matches facts with the given value
  • "certname": matches facts for the given node

Operators

See the Operators page

Examples

Using curl from localhost:

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"}]

GET /v3/facts/<NAME>

This will return all facts for all nodes with the indicated name.

URL Parameters

  • query: Optional. A JSON array containing the query in prefix notation. The syntax and semantics are identical to the query 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.

Examples

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"}]

GET /v3/facts/<NAME>/<VALUE>

This will return all facts for all nodes with the indicated name and value.

URL Parameters

  • query: Optional. A JSON array containing the query in prefix notation. The syntax and semantics are identical to the query 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.

Examples

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}]

Paging

This query endpoint supports paged results via the common PuppetDB paging query parameters. For more information, please see the documentation on paging.

Response Format

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.