From 7a3e3ad68fe5b14fc9a7ecbad10994dcf97c118f Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 25 Oct 2020 10:53:55 +0100 Subject: [PATCH] bundles/powerdns: we don't need the node names of primary nameservers --- bundles/powerdns/files/pdns.conf | 3 ++- bundles/powerdns/metadata.py | 25 +++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bundles/powerdns/files/pdns.conf b/bundles/powerdns/files/pdns.conf index 27fa53b..c79444a 100644 --- a/bundles/powerdns/files/pdns.conf +++ b/bundles/powerdns/files/pdns.conf @@ -14,7 +14,8 @@ server-id=${my_hostname} default-ttl=60 % if is_secondary: -# Primary servers: ${', '.join(sorted(my_primary_servers['nodes']))} +allow-notify-from=${','.join(sorted(my_primary_servers))} + slave=yes superslave=yes allow-notify-from=${','.join(sorted(my_primary_servers['ips']))} diff --git a/bundles/powerdns/metadata.py b/bundles/powerdns/metadata.py index 1161c37..403bba4 100644 --- a/bundles/powerdns/metadata.py +++ b/bundles/powerdns/metadata.py @@ -27,26 +27,39 @@ defaults = { } +@metadata_reactor +def get_ips_of_secondary_nameservers(metadata): + if metadata.get('powerdns/is_secondary', False): + return {} + + ips = set() + for rnode in repo.nodes_in_group('dns'): + if rnode.metadata.get('powerdns/is_secondary', False): + ips.update({ + str(ip) for ip in repo.libs.tools.resolve_identifier(repo, rnode.name) + }) + + return { + 'powerdns': { + 'my_secondary_servers': ips, + }, + } + @metadata_reactor def get_ips_of_primary_nameservers(metadata): if not metadata.get('powerdns/is_secondary', False): return {} ips = set() - nodes = set() for rnode in repo.nodes_in_group('dns'): if not rnode.metadata.get('powerdns/is_secondary', False): ips.update({ str(ip) for ip in repo.libs.tools.resolve_identifier(repo, rnode.name) }) - nodes.add(rnode.name) return { 'powerdns': { - 'my_primary_servers': { - 'ips': ips, - 'nodes': nodes, - }, + 'my_primary_servers': ips, }, }