Query puppet facts from PuppetDB through a DNS interface.
943
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 app1.brussels.puppetdb
app1.brussels.puppetdb has address 192.168.99.1
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
bind: 127.0.0.1
port: 5353
ttl: 86400
verbose: true
puppetdb: http://puppetdb.prd.srv.mycompany.be:8080
hierarchy:
- [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 app1.brussels.puppetdb, with the previous confiugration file, there will be two queries on puppetdb:
["and", ["=", ["fact", "role"], "app1"], ["=", ["fact", "datacenter"], "brussels"]]["and", ["=", ["fact", "subgroup"], "app1"], ["=", ["fact", "zone"], "brussels"]]The easiest way to install is to run:
$ curl -L https://github.com/jfroche/puppetdb-dns/releases/download/0.1/puppetdb-dns-linux-amd64 > puppetdb-dns
$ chmod +x puppetdb-dns
If you have go on your machine:
$ go get github.com/jfroche/puppetdb-dns
$ go install github.com/jfroche/puppetdb-dns
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 novac.site.prod.plone.cicd
The yaml configuration file should contain these keys:
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
Content type
Unrecognized
Digest
Size
80.2 MB
Last updated
almost 10 years ago
docker pull jfroche/puppetdb-dns