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, }, }