Created
January 25, 2018 01:57
-
-
Save jpadams/4ba7b4f50bf76e035a6d6b6a24b79779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function prettyStructured (k,v) { | |
| try {if (k == "value" && typeof(JSON.parse(v)) == "object") { | |
| v = JSON.stringify(JSON.parse(v), null, 2).replace(/\n/g, "\n"); | |
| } } catch(e) {} | |
| return v; | |
| } | |
| JSON.stringify(facts, prettyStructured ,2) | |
| facts = [ ... | |
| { | |
| "name": "processors", | |
| "value": "{\"isa\":\"x64\",\"count\":4,\"models\":[\"Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz\",\"Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz\",\"Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz\",\"Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz\"],\"physicalcount\":4}", | |
| "environment": "production", | |
| "id": "mission-3-processors" | |
| }, | |
| ... | |
| ] | |
| cat new-win-facts.json | jq '[.[] | if (.value | type)=="object" then (.value=(.value | tojson)) else (.value=.value) end]' > facts.json | |
| cat win-facts.json | jq '[.[] | .id = "\(.id)-\(.name)"]' > new-win-facts.json | |
| use sed or jq or vi or whatever to transform certname into "id" | |
| puppet query 'facts [name,value,environment,certname]{certname = "win-2016-2.tse.puppetlabs.net"}' > win-facts.json | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment