Puppet in Docker How do I query PuppetDB API in a container setup

0 votes
How can I query the PuppetDB to fetch data of all the nodes using the API?
Aug 20, 2019 in Puppet by Karan
• 19,610 points
880 views

1 answer to this question.

0 votes

PuppetDB exposes a dashboard, showing various operational metrics, as well as an API for accessing all the collected resource data. You can find the port for the dashboard using docker ps

The docker port command can also be useful.

$ docker port compose_puppetdb_1
8080/tcp -> 0.0.0.0:32826
8081/tcp -> 0.0.0.0:32825

With that port in hand, and the ip address of the machine running docker, you can query the PuppetDB API.

$ curl -s -X GET http://192.168.99.100:32826/pdb/query/v4 --data-urlencode 'query=nodes {}' | jq

Here I'm issuing a PQL query for all nodes. I'm parsing it through jq for nicer formatting.

This will give you an output something similar to this:

{
    "deactivated": null,
    "latest_report_hash": "f8332ac22e0abf6a51571fae6b57b2a881f207fe",
    "facts_environment": "production",
    "cached_catalog_status": "not_used",
    "report_environment": "production",
    "catalog_environment": "production",
    "facts_timestamp": "2016-05-27T12:47:04.495Z",
    "latest_report_noop": false,
    "expired": null,
    "report_timestamp": "2016-05-27T12:47:04.144Z",
    "certname": "a9efc038b3ca",
    "catalog_timestamp": "2016-05-27T12:47:05.038Z",
    "latest_report_status": "changed"
  },
  {
    "deactivated": null,
    "latest_report_hash": "d273124e1e74708272228ac4465f6f1923100db7",
    "facts_environment": "production",
    "cached_catalog_status": "not_used",
    "report_environment": "production",
    "catalog_environment": "production",
    "facts_timestamp": "2016-05-27T12:47:37.543Z",
    "latest_report_noop": false,
    "expired": null,
    "report_timestamp": "2016-05-27T12:47:36.959Z",
    "certname": "5a4cbf61e790",
    "catalog_timestamp": "2016-05-27T12:47:38.050Z",
    "latest_report_status": "changed"
  }
]

answered Aug 20, 2019 by Sirajul
• 59,230 points

Related Questions In Puppet

0 votes
1 answer

Puppet in Docker : How do i run my dockerized puppet container periodically?

Instead of running a Dockerized puppet container onetime, ...READ MORE

answered Aug 19, 2019 in Puppet by Sirajul
• 59,230 points
714 views
0 votes
1 answer

Puppet: How do i setup puppet module behind a proxy?

To use the puppet module command behind a proxy, ...READ MORE

answered Aug 9, 2019 in Puppet by Sirajul
• 59,230 points
2,891 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,090 points
2,436 views
0 votes
1 answer

Puppet+Docker: How do i configure my docker container to use a NFS volume?

docker_volume { 'nfs-volume': ensure => ...READ MORE

answered Aug 13, 2019 in Puppet by Sirajul
• 59,230 points
520 views
0 votes
1 answer

Puppet+Docker: How do i configure my docker container to use a NFS volume through a Hiera config file?

If using Hiera, configure the docker::volumes class in the ...READ MORE

answered Aug 14, 2019 in Puppet by Sirajul
• 59,230 points
718 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP