how to use the puppetdb api to combine facts and get the output

asked 2018-11-21 06:27:19 -0600

dmccuk gravatar image

I'm using puppet version 5.3.6.

I'm able to query the puppetdb and get lots of useful information like this:

$ curl -s -X GET http://localhost:8080/pdb/query/v4/facts --data-urlencode 'query=["extract", [["function","count"],"value"],["=","name","operatingsystem"],["group_by", "value"]]' | python -mjson.tool
[
    {
        "count": 339,
        "value": "OracleLinux"
    },
    {
        "count": 73,
        "value": "RedHat"
    }
]

AND:

$ curl -s -X GET http://localhost:8080/pdb/query/v4/facts --data-urlencode 'query=["extract", [["function","count"],"value"],["=","name","operatingsystemmajrelease"],["group_by", "value"]]' | python -mjson.tool
[
    {
        "count": 38,
        "value": "5"
    },
    {
        "count": 217,
        "value": "6"
    },
    {
        "count": 157,
        "value": "7"
    }
]

How can I combine the two together and get each Oracle/Red Hat release & major release grouped together in an easy to see view. I've tried a few different ways to do it but I'm not able to find any examples or docs that can explain to me how to do it.

Thanks for your help!

Regards

edit retag flag offensive close merge delete