pypuppetdb
Python library for working with the PuppetDB API
A Python library that wraps PuppetDB's web API in simple commands, letting you query your servers, their facts, and configurations without hand-writing raw queries.
pypuppetdb
PuppetDB is a tool that IT teams use to keep track of all the servers and software they manage. This library makes it easy for Python developers to write programs that ask PuppetDB questions and get answers back—like "show me all my Linux servers" or "what's the current state of the apache service across my infrastructure?"
Think of it as a translator. PuppetDB has a web API (a way for programs to talk to it), but that API is pretty low-level and requires you to write out complex queries by hand. This library wraps that API and gives you simpler Python commands instead. For example, instead of building a long query string, you can just write db.nodes() to get a list of all your servers, or db.facts('osfamily') to find out what operating systems you're running. The library handles all the messy details of connecting, formatting requests, and turning the responses into objects your code can work with.
The library lets you query several types of information: nodes (your servers), facts (attributes about those servers like OS type), resources (things like files and services that are managed), and catalogs (complete snapshots of what's supposed to be configured on a particular server). You can also see relationships between resources—for instance, which files trigger which services to restart. For advanced users, there's a query builder that lets you construct complex filters in an object-oriented way rather than writing raw query strings.
This would be useful for anyone writing tools to manage Puppet infrastructure—operations teams building dashboards, automation scripts that need to look up server information, or anyone integrating PuppetDB data into their own systems. The project has been around for a while, is actively maintained by the Puppet community, and includes full documentation and a test suite.
Where it fits
- List all servers managed by Puppet with a single db.nodes() call.
- Look up a fact like operating system across your whole infrastructure with db.facts().
- Build an operations dashboard that shows the current state of services across servers.
- Use the query builder to construct complex filters over nodes, resources, and catalogs.