PuppetDB & exported resources

Cross-node orchestration.

Advanced12 min · lesson 11 of 12

PuppetDB is a database that stores everything Puppet knows — every node’s facts, catalogs, and run reports — and makes it queryable. That powers a lot: fast fact queries across the fleet (“which nodes run this kernel”), reporting and dashboards, and the standout feature, exported resources, which let one node declare a resource that other nodes collect and realize. It is how Puppet does cross-node coordination.

EXPORTED RESOURCES ACROSS NODES
1Export
web nodes declare @@haproxy::balancermember
2PuppetDB
stores facts, catalogs, and exported resources
3Collect
LB realizes Haproxy::Balancermember <<| |>>
4Pool updated
backends added automatically on next LB run
Web nodes export backend entries; the load balancer collects them on its next run, so the pool stays current with no manual list (with inherent lag until both have run).
exported resources
# on each web node: EXPORT a load-balancer backend entry
@@haproxy::balancermember { $facts['networking']['fqdn']:
ipaddress => $facts['networking']['ip'],
port => 8080,
}
# on the load balancer: COLLECT all exported entries
Haproxy::Balancermember <<| |>> # realizes every web node’s backend automatically

Orchestration without a central list

Exported resources solve the classic “each backend registers itself with the load balancer” problem without maintaining a manual list: web nodes export their backend entry as they are provisioned, the LB collects them on its next run, and the pool stays current automatically. PuppetDB also feeds the puppet query language (PQL) for ad-hoc fleet questions, useful for audits and incident response.

terminal
$ puppet query 'inventory[certname] { facts.os.family = "Debian" }'
[ {"certname":"web1.acme.internal"}, {"certname":"web2.acme.internal"} ]
# ask the fleet a question directly from PuppetDB
Exported resources add ordering and staleness caveats
A collector only sees exports after those nodes have run and written to PuppetDB, so a brand-new backend appears in the LB pool only after both nodes have completed a run — there is an inherent lag. And stale exports linger until purged. Understand the eventual-consistency behavior before relying on exported resources for anything time-sensitive, and clean up exports when nodes are decommissioned.