Project

General

Profile

Actions

Bug #20829

open

Structured facts are stringified

Added by Luke Simmons over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Facts
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Take a JSON file. Something like this:

  1. cat /etc/facter/facts.d/keystores.json
    {
            "keystores": [{
                    "file1.jks": {
                            "foo_root_ca_v1": {
                                    "remaining_days": 5324,
                                    "owner": "CN=FOO, O=BAR, C=SE",
                                    "issuer": "CN=FOO Root CA v1, O=BAR, C=SE" 
                            }
                    }
            }]
    }
    

This will result in a JSON string via an API call to https://foreman.domain.com/api/v2/hosts/:host_id/facts?search=keystores:

{
  "total": 374,
  "subtotal": 1,
  "page": 1,
  "per_page": 200,
  "search": "keystores host = 62",
  "sort": {
    "by": null,
    "order": null
  },
  "results": {"foo.domain.com":{"keystores":"[{\"file1.jks\"=>{\"foo_root_ca_v1\"=>{\"issuer\"=>\"CN=FOO Root CA v1, O=BAR, C=SE\", \"owner\"=>\"CN=FOO, O=BAR, C=SE\", \"remaining_days\"=>5324}}}]"}}
}

The keystores hash should not be stringified. This fact, it should be noted, will work fine in Puppet. I'm guessing the POST request to Foreman, when uploading the fact, is stringifying everything after the facter variable.

To test this facter variable on Puppet, run "puppet apply" on the following code:

$file = $::keystores[0]['file1.jks']["foo_root_ca_v1"]["remaining_days"]
notice "$file" 

No data to display

Actions

Also available in: Atom PDF