Public | Automated Build

Last pushed: a year ago
Short Description
Query puppet facts from PuppetDB through a DNS interface.
Full Description


Query puppet facts from PuppetDB
through a DNS interface.

We use the role/profile pattern. Each machines have a role.
As our infrastructure become more and more complex we would like to quickly lookup nodes that match criteria.
E.g. give me the servers with the app1 role in datacenter brussels should be as simple as:

# host has address

But you might want as well query nodes using other facts. That's why we made a configuration file that list the combinations
of facts that can be used together:

domain: puppetdb
port: 5353
ttl: 86400
verbose: true
  - [role, datacenter]
  - [subgroup, zone]
  - [subgroup, role, zone]
  - [subgroup, role, zone, hostgroup]

Every part of the subdomain will be mapped to each element of the hierachy. So if we query, with the previous confiugration file, there will be two queries on puppetdb:

  1. ["and", ["=", ["fact", "role"], "app1"], ["=", ["fact", "datacenter"], "brussels"]]
  2. ["and", ["=", ["fact", "subgroup"], "app1"], ["=", ["fact", "zone"], "brussels"]]


The easiest way to install is to run:

$ curl -L > puppetdb-dns
$ chmod +x puppetdb-dns

If you have go on your machine:

$ go get
$ go install


To run puppetdb-dns with a configuration file:

$ puppetdb-dns -conf dns.conf

To run puppetdb-dns with dns.conf as default configuration file:

$ puppetdb-dns

You can query your local puppetdb-dns using dig:

$ dig @localhost -p 5353

Configuration file

The yaml configuration file should contain these keys:

  • domain (text): the domain that the dns server answer to
  • bind (text): network ip the dns server listen to
  • port (int): port the dns server listen to
  • ttl (int): time to live of the resource records
  • verbose (bool): print debug information
  • puppetdb (text): URL of the puppetdb to query
  • hierarchy (list of list of string): contains the list of list of facts that will be mapped against dns query


puppetdb-dns can be run using docker.

Create your dns.conf file and run:

$ docker run --rm -p 5353:5353 -v $(pwd)/dns.conf:/go/dns.conf jfroche/puppetdb-dns

Based on:

Docker Pull Command
Source Repository