bundles/powerdns: add metadata reactor for automatic node-dns-generation
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
793220c0ec
commit
4d6b867bb3
1 changed files with 33 additions and 18 deletions
|
@ -52,25 +52,40 @@ def get_ips_of_primary_nameservers(metadata):
|
||||||
|
|
||||||
|
|
||||||
@metadata_reactor
|
@metadata_reactor
|
||||||
def get_ips_of_primary_nameserver(metadata):
|
def generate_dns_entries_for_nodes(metadata):
|
||||||
if not metadata.get('powerdns/is_secondary', False):
|
results = set()
|
||||||
return {}
|
|
||||||
|
|
||||||
ips = set()
|
|
||||||
for rnode in repo.nodes:
|
for rnode in repo.nodes:
|
||||||
if not node.has_bundle('powerdns'):
|
node_name_split = rnode.name.split('.')
|
||||||
continue
|
node_name_split.reverse()
|
||||||
|
dns_name = '.'.join(node_name_split)
|
||||||
|
ip4 = None
|
||||||
|
ip6 = None
|
||||||
|
|
||||||
if node.name in rnode.metadata.get('powerdns/my_secondary_servers', set()):
|
# We only need this for GCE, because machines over there don't
|
||||||
return {
|
# have a public ipv4 address.
|
||||||
'powerdns': {
|
if rnode.metadata.get('external_ipv4', None):
|
||||||
'my_primary_server': {
|
ip4 = rnode.metadata.get('external_ipv4')
|
||||||
'ips': {
|
|
||||||
str(ip) for ip in repo.libs.tools.resolve_identifier(repo, rnode.name)
|
for iface, config in sorted(rnode.metadata.get('interfaces', {}).items()):
|
||||||
},
|
if not ip4 and 'ipv4' in config:
|
||||||
'node': rnode.name,
|
ip4 = sorted(config['ipv4'])[0]
|
||||||
},
|
|
||||||
|
if not ip6 and 'ipv6' in config:
|
||||||
|
ip6 = sorted(config['ipv6'])[0]
|
||||||
|
|
||||||
|
if ip4:
|
||||||
|
results.add('{} IN A {}'.format(dns_name, ip4))
|
||||||
|
|
||||||
|
if ip6:
|
||||||
|
results.add('{} IN AAAA {}'.format(dns_name, ip6))
|
||||||
|
|
||||||
|
return {
|
||||||
|
'powerdns': {
|
||||||
|
'bind-zones': {
|
||||||
|
'kunbox.net': {
|
||||||
|
'records': results,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
},
|
||||||
return {}
|
}
|
||||||
|
|
Loading…
Reference in a new issue