from bundlewrap.exceptions import NoSuchGroup defaults = { 'apt': { 'packages': { 'pdns-server': {}, 'pdns-tools': {}, 'pdns-backend-bind': {}, 'pdns-backend-pgsql': {}, }, }, 'powerdns': { 'api_key': repo.vault.password_for('{} powerdns api'.format(node.name)), }, 'postgresql': { 'users': { 'powerdns': { 'password': repo.vault.password_for('{} postgresql powerdns'.format(node.name)), }, }, 'databases': { 'powerdns': { 'owner': 'powerdns', }, }, }, } @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, }, }, } @metadata_reactor def get_ips_of_primary_nameserver(metadata): if not metadata.get('powerdns/is_secondary', False): return {} ips = set() for rnode in repo.nodes: if not node.has_bundle('powerdns'): continue if node.name in rnode.metadata.get('powerdns/my_secondary_servers', set()): return { 'powerdns': { 'my_primary_server': { 'ips': { str(ip) for ip in repo.libs.tools.resolve_identifier(repo, rnode.name) }, 'node': rnode.name, }, }, } return {}