On Friday, February 6, 2015 at 2:13:21 PM UTC-6, Steve Harp wrote: > > Hi Guys, > > I have a json configuration file on each Puppet Agent that I need to parse > and return the values as custom facts. Each json file will contain an > array of from 0 to n elements each of which will have needed configuration > settings. I think what I need to write is an aggregate fact where the > specific elements in the array will be represented as chunks. >
The Puppet term for what you appear to want is a "structured fact". The Facter documentation contains a section on writing structured facts <https://docs.puppetlabs.com/facter/2.0/fact_overview.html#writing-structured-facts> . > I don't think writing the fact would be too difficult > Probably not, supposing you have a JSON parser in your local Ruby lib. Such a parser probably produces an appropriate fact value in about one line. > but I don't know how to reference the facts from within a manifest on the > Puppet Master. I would like to be able to access these settings using a > custom fact from within a manifest. Something like: > > value=Sites[2]["LIVE_DIR"] > > and have the variable, value, set to '/srv/www/test-0000.net'. > > If you have an aggregate fact, how to you use it in a manifest? > Referencing facts is no different from referencing any other Puppet variable. If the name of the fact were "sites" (should be lowercase) and its value were structured as an array of hashes, then you would use $value = $sites[2]["LIVE_DIR"] (The Puppet documentation describes the syntax for referencing array and hash elements <https://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html>. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/4b3a722f-7cc3-441a-96bb-dc3e83a54f20%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.