Skip to content

Instantly share code, notes, and snippets.

@wido
Created November 25, 2015 08:01
Show Gist options
  • Save wido/84b4ceb56c9d4b26658f to your computer and use it in GitHub Desktop.
Save wido/84b4ceb56c9d4b26658f to your computer and use it in GitHub Desktop.
Use Local Salt client to populate DNS
#!/usr/bin/env python
"""
Fetch all IPv6 addresses of Minions and generate local
unbound data based on the output
"""
import json
import salt.client
import salt.output.json_out
local = salt.client.LocalClient()
ret = local.cmd('*', 'grains.get', ['ipv6:0'])
for host, addr in ret.items():
print("local-data: \"%s. 1h IN AAAA %s\"" % (host, addr))
print("local-data-ptr: \"%s 1h %s.\"" % (addr, host))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment