Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@martingehrke
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martingehrke/ce1e5e8aa314bc0d912e to your computer and use it in GitHub Desktop.
Save martingehrke/ce1e5e8aa314bc0d912e to your computer and use it in GitHub Desktop.
How to get a list of values out of json in CFEngine 3.6+
#it can be non-intuitive to get a slist from a json data object in CFEngine
# this can be useful if you have a json with hostnames as keys
vars:
"data" data => parsejson("{ "key": ["one", "two", "three"] }");
"values" slist => getvalues("data[key]"); #just pass the name, not the variable itself
#just an example, I haven't loaded moredata in this gist
"info" slist => getvalues("moredata[$(sys.fqhost)]");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment