PuppetDB 1.5 » API » v3 » Querying Facts

Included in Puppet Enterprise 3.2. A newer version is available; see the version menu above for details.

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.

↑ Back to top