File: inventory.markdown

package info (click to toggle)
puppetdb 8.8.1-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 19,692 kB
  • sloc: javascript: 23,285; ruby: 5,620; sh: 3,457; python: 389; xml: 114; makefile: 38
file content (116 lines) | stat: -rw-r--r-- 3,658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
title: "Inventory endpoint"
layout: default
canonical: "/puppetdb/latest/api/query/v4/inventory.html"
---
# Inventory endpoint

[curl]: ../curl.markdown#using-curl-from-localhost-non-sslhttp
[subqueries]: ./ast.markdown#subquery-operators
[dotted]: ./ast.markdown#dot-notation
[environments]: ./environments.markdown
[factsets]: ./factsets.markdown
[catalogs]: ./catalogs.markdown
[facts]: ./facts.markdown
[fact-contents]: ./fact-contents.markdown
[events]: ./events.markdown
[edges]: ./edges.markdown
[resources]: ./resources.markdown
[nodes]: ./nodes.markdown
[query]: query.markdown
[ast]: ./ast.markdown

The `/inventory` endpoint provides an alternate and potentially more
efficient way to access structured facts as compared to the `facts`,
`fact-contents`, and `factsets` endpoints.

## `/pdb/query/v4/inventory`

This will return an array of `node inventories` matching the given query.
Inventories for deactivated nodes are not included in the response.

### URL parameters

* `query`: optional. A JSON array containing the query in prefix notation
  (`["<OPERATOR>", "<FIELD>", "<VALUE>"]`). See the sections below for the
  supported operators and fields. For general information about queries, see
  [our guide to query structure.][query]

### Query operators

See [the AST query language page][ast] for the full list of available operators.

> **Note:** This endpoint supports [dot notation][dotted] on the `facts` and
`trusted` response fields.

### Query fields

* `certname` (string): the name of the node associated with the inventory.

* `timestamp` (string): the time at which PuppetDB received the facts in the inventory.

* `environment` (string): the environment associated with the inventory's
  certname.

* `facts` (json): a JSON hash of fact names to fact values.

* `trusted` (json): a JSON hash of trusted data for the node.

### Response format

Successful responses will be in `application/json`.

The result will be a JSON array with one entry per certname. Each entry is of
the form:

    {
      "certname": <node certname>,
      "timestamp": <timestamp of fact reception>,
      "environment": <node environment>,
      "facts": {
                 <fact name>: <fact value>,
                 ...
               },
      "trusted": {
                   <data name>: <data value>,
                   ...
                 }
    }

### Examples

[Using `curl` from localhost][curl]

    curl -X GET http://localhost:8080/pdb/query/v4/inventory -d 'query=["=", "facts.operatingsystem", "Darwin"]'

    [ {
        "certname" : "mbp.local",
            "timestamp" : "2016-07-11T20:02:33.190Z",
            "environment" : "production",
            "facts" : {
                "kernel" : "Darwin",
                "operatingsystem" : "Darwin",
                "memoryfree" : "3.51 GB",
                "macaddress_p2p0" : "0e:15:c2:d6:f8:4e",
                "system_uptime" : {
                    "days" : 0,
                    "hours" : 1,
                    "uptime" : "1:52 hours",
                    "seconds" : 6733
                },
                "netmask_lo0" : "255.0.0.0",
                "sp_physical_memory" : "16 GB",
                "operatingsystemrelease" : "14.4.0",
                "macosx_productname" : "Mac OS X",
                "sp_boot_mode" : "normal_boot",
                "macaddress_awdl0" : "6e:31:ef:e6:36:54",
                ...
            },
            "trusted" : {
                "domain" : "local",
                "certname" : "mbp.local",
                "hostname" : "mbp",
                "extensions" : { },
                "authenticated" : "remote"
            }
    } ]