acidprime / exports

A puppet face that queries puppetdb and returns the exported resources
7 stars 7 forks source link

(METHOD-405) Support PuppetDB API v4 #6

Closed jveski closed 8 years ago

jveski commented 8 years ago

This commit adds logic to analyze the PuppetDB terminus and determine a preferred version of the query API. Ideally we would have a means of programmatically accessing the PuppetDB's version, but relying on the terminus interface is fairly safe in this case since a specific change to the interface corresponds with the removal of the v2 / v3 endpoints.

The logic also allows PDB server and port to be configured from both the previous and current versions of the PuppetDB terminus. In the case that multiple PuppetDB instances have been configured, only the first will be used.

In the future it may be advantageous to use the PuppetDB resources terminus instead of making an unabstracted HTTP request. This would be more maintainable and allow for the use of multiple PuppetDB instances. The logic is necessary in the current design as the PuppetDB resources terminus only allows for querying exported resources of a specific type.

binford2k commented 8 years ago

:+1:

pdb4

root@master:/etc/puppetlabs/code/modules/exports/lib/puppet/face/node # puppet node exports
Name                                      Exports
master.puppetlabs.vm                      Puppet_enterprise::certs::rbac_whitelist_entry[export: master.puppetlabs.vm-for-rbac]
master.puppetlabs.vm                      Puppet_enterprise::amq::config::network_connector[export: master.puppetlabs.vm-topic]
master.puppetlabs.vm                      Puppet_enterprise::certs::puppetdb_whitelist_entry[export: master.puppetlabs.vm-for-puppetdb-whitelist]
master.puppetlabs.vm                      Puppet_enterprise::amq::config::network_connector[export: master.puppetlabs.vm-queue]

pdb3

puppet node exports
Name                                      Exports
master.puppetlabs.vm                      Puppet_enterprise::certs::rbac_whitelist_entry[export: master.puppetlabs.vm-for-rbac]
master.puppetlabs.vm                      Puppet_enterprise::amq::config::network_connector[export: master.puppetlabs.vm-topic]
master.puppetlabs.vm                      Puppet_enterprise::certs::dashboard_whitelist_entry[export: master.puppetlabs.vm-for-dashboard]
master.puppetlabs.vm                      Puppet_enterprise::certs::puppetdb_whitelist_entry[export: master.puppetlabs.vm-for-puppetdb-whitelist]
master.puppetlabs.vm                      Puppet_enterprise::amq::config::network_connector[export: master.puppetlabs.vm-queue]