how to use the puppetdb API to combine facts
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
add a comment |
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
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 thefacts
andquery 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
add a comment |
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
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
api curl puppet
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 thefacts
andquery 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
add a comment |
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 thefacts
andquery 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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
andquery 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