how to use the puppetdb API to combine facts












0















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.



Other useful combinations would be all Red Hat servers in a particular DC running operatingsystemmajrelease 6 (or show all of them?). This would involve combining three facts.



This would be very ussful.



Thanks for your help!



Regards










share|improve this question


















  • 1





    Your best bet here is to write a wrapper script around your queries that combines and formats the responses. I would recommend the Python bindings to greatly facilitate that: github.com/voxpupuli/pypuppetdb. I do not have enough experience around the Python bindings for the PuppetDB REST API to give an answer, but this will definitely help you out. Specifically check out the facts and query builder sections of the documentation.

    – Matt Schuchard
    Nov 21 '18 at 16:40













  • I was hoping i could combine my query with an "and" or an "or" to help build up the matches and results. I will check out the ling thanks Matt. If someone doesn know if this is possible I'd be happy to hear. Thanks

    – Live_
    Nov 21 '18 at 16:43













  • Well you can definitely do that that kind of query enhancement with the Python bindings. If your hope was to do it with curl, then I think you would get stuck writing complicated shell scripts.

    – Matt Schuchard
    Nov 21 '18 at 16:44
















0















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.



Other useful combinations would be all Red Hat servers in a particular DC running operatingsystemmajrelease 6 (or show all of them?). This would involve combining three facts.



This would be very ussful.



Thanks for your help!



Regards










share|improve this question


















  • 1





    Your best bet here is to write a wrapper script around your queries that combines and formats the responses. I would recommend the Python bindings to greatly facilitate that: github.com/voxpupuli/pypuppetdb. I do not have enough experience around the Python bindings for the PuppetDB REST API to give an answer, but this will definitely help you out. Specifically check out the facts and query builder sections of the documentation.

    – Matt Schuchard
    Nov 21 '18 at 16:40













  • I was hoping i could combine my query with an "and" or an "or" to help build up the matches and results. I will check out the ling thanks Matt. If someone doesn know if this is possible I'd be happy to hear. Thanks

    – Live_
    Nov 21 '18 at 16:43













  • Well you can definitely do that that kind of query enhancement with the Python bindings. If your hope was to do it with curl, then I think you would get stuck writing complicated shell scripts.

    – Matt Schuchard
    Nov 21 '18 at 16:44














0












0








0








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.



Other useful combinations would be all Red Hat servers in a particular DC running operatingsystemmajrelease 6 (or show all of them?). This would involve combining three facts.



This would be very ussful.



Thanks for your help!



Regards










share|improve this question














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.



Other useful combinations would be all Red Hat servers in a particular DC running operatingsystemmajrelease 6 (or show all of them?). This would involve combining three facts.



This would be very ussful.



Thanks for your help!



Regards







api curl puppet






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 14:44









Live_Live_

11




11








  • 1





    Your best bet here is to write a wrapper script around your queries that combines and formats the responses. I would recommend the Python bindings to greatly facilitate that: github.com/voxpupuli/pypuppetdb. I do not have enough experience around the Python bindings for the PuppetDB REST API to give an answer, but this will definitely help you out. Specifically check out the facts and query builder sections of the documentation.

    – Matt Schuchard
    Nov 21 '18 at 16:40













  • I was hoping i could combine my query with an "and" or an "or" to help build up the matches and results. I will check out the ling thanks Matt. If someone doesn know if this is possible I'd be happy to hear. Thanks

    – Live_
    Nov 21 '18 at 16:43













  • Well you can definitely do that that kind of query enhancement with the Python bindings. If your hope was to do it with curl, then I think you would get stuck writing complicated shell scripts.

    – Matt Schuchard
    Nov 21 '18 at 16:44














  • 1





    Your best bet here is to write a wrapper script around your queries that combines and formats the responses. I would recommend the Python bindings to greatly facilitate that: github.com/voxpupuli/pypuppetdb. I do not have enough experience around the Python bindings for the PuppetDB REST API to give an answer, but this will definitely help you out. Specifically check out the facts and query builder sections of the documentation.

    – Matt Schuchard
    Nov 21 '18 at 16:40













  • I was hoping i could combine my query with an "and" or an "or" to help build up the matches and results. I will check out the ling thanks Matt. If someone doesn know if this is possible I'd be happy to hear. Thanks

    – Live_
    Nov 21 '18 at 16:43













  • Well you can definitely do that that kind of query enhancement with the Python bindings. If your hope was to do it with curl, then I think you would get stuck writing complicated shell scripts.

    – Matt Schuchard
    Nov 21 '18 at 16:44








1




1





Your best bet here is to write a wrapper script around your queries that combines and formats the responses. I would recommend the Python bindings to greatly facilitate that: github.com/voxpupuli/pypuppetdb. I do not have enough experience around the Python bindings for the PuppetDB REST API to give an answer, but this will definitely help you out. Specifically check out the facts and query builder sections of the documentation.

– Matt Schuchard
Nov 21 '18 at 16:40







Your best bet here is to write a wrapper script around your queries that combines and formats the responses. I would recommend the Python bindings to greatly facilitate that: github.com/voxpupuli/pypuppetdb. I do not have enough experience around the Python bindings for the PuppetDB REST API to give an answer, but this will definitely help you out. Specifically check out the facts and query builder sections of the documentation.

– Matt Schuchard
Nov 21 '18 at 16:40















I was hoping i could combine my query with an "and" or an "or" to help build up the matches and results. I will check out the ling thanks Matt. If someone doesn know if this is possible I'd be happy to hear. Thanks

– Live_
Nov 21 '18 at 16:43







I was hoping i could combine my query with an "and" or an "or" to help build up the matches and results. I will check out the ling thanks Matt. If someone doesn know if this is possible I'd be happy to hear. Thanks

– Live_
Nov 21 '18 at 16:43















Well you can definitely do that that kind of query enhancement with the Python bindings. If your hope was to do it with curl, then I think you would get stuck writing complicated shell scripts.

– Matt Schuchard
Nov 21 '18 at 16:44





Well you can definitely do that that kind of query enhancement with the Python bindings. If your hope was to do it with curl, then I think you would get stuck writing complicated shell scripts.

– Matt Schuchard
Nov 21 '18 at 16:44












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414540%2fhow-to-use-the-puppetdb-api-to-combine-facts%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53414540%2fhow-to-use-the-puppetdb-api-to-combine-facts%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]