Project

General

Profile

Json-fact-format » History » Version 8

Marek Hulán, 01/26/2014 11:41 AM

1 1 Romain Vrignaud
h1. Json-fact-format
2
3
h3. how to send facts
4
5
* Foreman reports need to be sent to /api/hosts/facts
6 3 Marek Hulán
* Following headers needs to be present: 
7 1 Romain Vrignaud
<pre>
8
  "Accept: application/json,version=2"
9
  "Content-Type: application/json"
10
</pre>
11
12
h3. facts JSON format
13
14 7 Marek Hulán
15
<pre><code class="json">
16 1 Romain Vrignaud
{
17 7 Marek Hulán
  "name"     : "fqdn.example.com",
18
  "certname" : "optional.certname.for.this.host",
19
  "facts"    : {
20
                  "fact1"                  : "value",
21
                  "fact2"                  : "value",
22 8 Marek Hulán
                  "fact2::nested::fact"    : "value",
23 7 Marek Hulán
                  "_timestamp"             : "2013-10-18 07:47:45 +0000",
24
                  "_type"                  : "puppet",
25
                  "operatingsystem"        : "Debian",
26
                  "operatingsystemrelease" : "7.0"
27 8 Marek Hulán
               }
28 5 Greg Sutcliffe
}
29 7 Marek Hulán
</code></pre>
30
31 1 Romain Vrignaud
32 6 Marek Hulán
Note that _timestamp, operatingsystem and operatingsystemrelease are mandatory. Certname is optional, but if provided it will be preferred over name to identify the host object in the db. _type identifies source of fact, currently only puppet is supported by Foreman core and is also a default value if unspecified. If you want to add another fact type, you can register your importer class in FactImporter.register_fact_importer. For more info and example see https://github.com/ares/foreman_chef