curl -s -G http://localhost:8080/pdb/query/v4/reports --data-urlencode 'query=["=","latest_report?","true"]'| jq '.[] | {certname: .certname, receive_time: .receive_time}'
retrieve last_report older than 30 minutes :
curl -s -G http://localhost:8080/pdb/query/v4/reports --data-urlencode "query=[\"and\",[\"<\",\"receive_time\",\"$(date --utc +%Y-%m-%dT%H:%M -d '30 min ago')\"],[\"=\",\"latest_report?\",\"true\"]]"|jq '.[]| {certname: .certname, receive_time: .receive_time}'
Il faut récupérer le ca.pem du puppetmaster, et les certificats du puppetdb en question
sudo scp $(puppet master --configprint ssldir)/ca/ca_crt.pem puppetdb.example.com:/etc/puppetdb/ssl/ca.pem
$ sudo scp $(puppet master --configprint ssldir)/private_keys/puppetdb.example.com.pem puppetdb.example.com:/etc/puppetdb/ssl/private.pem
$ sudo scp $(puppet master --configprint ssldir)/certs/puppetdb.example.com.pem puppetdb.example.com:/etc/puppetdb/ssl/public.pem
/etc/puppetdb/conf.d/jetty.ini
ssl-host = 0.0.0.0
ssl-port = 8081
ssl-key = /etc/puppetdb/ssl/private.pem
ssl-cert = /etc/puppetdb/ssl/public.pem
ssl-ca-cert = /etc/puppetdb/ssl/ca.pem
With SSL:
curl -X GET https://puppetdb.example.com:8081/pdb/query/v4/resources \
--tlsv1 \
--cacert /etc/puppet/ssl/certs/ca.pem \
--cert /etc/puppet/ssl/certs/thisnode.pem \
--key /etc/puppet/ssl/private_keys/thisnode.pem \
--data-urlencode query@<filename>
This requires that you specify a certificate (issued by the same CA PuppetDB trusts), a private key, and a CA certificate.
In both examples, <filename> should be a file that contains the query to execute.
ror adapter to query puppetdb
Un frontend pour puppetdn (en python)
Comment construire la gem puppetdb-terminus à partir des sources github :
git clone https://github.com/puppetlabs/puppetdb
git checkout 1.6.2
cd puppetdb
cp contrib/gem/puppetdb-terminus.gemspec puppet/
cd puppet
modifier le spec pour mettre version=1.6.2
gem build puppetdb-terminus.gemspec
Installer la gem : gem install puppetdb-terminus-1.6.2.gem