how to use the puppetdb API to combine facts
up vote
0
down vote
favorite
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 |
up vote
0
down vote
favorite
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 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 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 at 16:44
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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 at 14:44
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 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 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 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 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 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 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 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 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 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 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 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 at 16:44
add a comment |
active
oldest
votes
active
oldest
votes
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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 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 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 at 16:44