I have a puppetdb query: "resources[certname,parameters]{type = 'my_special_type'}". The result looks like this:
[
{
"certname": "server1",
"parameters: {
"port": 1234,
"job": "job1"
}
]
Imagine a few dozen servers with five different jobs. Is there a way to transform that into an object that looks like:
[
{
"job": "job1",
"entries": ["server1:1234"]
}
]
Either by changing the query, or by using various Puppet functions to create a new hash?
Is this possible directly in Puppet, or should I give up and write a function in Ruby which can be called from Puppet (note: I'm not even sure that it's possible to pass a structure back to Puppet)?
If you need to know why I'm doing this: I'm trying to get nodes to self identify for various Prometheus scans. I've got that part working, so I can collect the necessary information form PuppetDB. Now I need to sort through it and create a config file.
↧