bundles/powerdns: add support for zone transfers
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
This commit is contained in:
parent
f2073e72ed
commit
ca1646d394
5 changed files with 78 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
from bundlewrap.exceptions import NoSuchGroup
|
||||
|
||||
defaults = {
|
||||
'apt': {
|
||||
'packages': {
|
||||
|
@ -23,3 +25,56 @@ defaults = {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
def get_ips_of_secondary_nameservers(metadata):
|
||||
# Secondary Nameservers can't be a primary nameserver at the same
|
||||
# time. Return early if this is a secondary server.
|
||||
if metadata.get('powerdns/is_secondary', False):
|
||||
return {}
|
||||
|
||||
try:
|
||||
nameservers = repo.nodes_in_group(metadata.get('powerdns/secondary_nameservers', ''))
|
||||
except NoSuchGroup:
|
||||
# This probably is no primary nameserver, either. Should be fine.
|
||||
return {}
|
||||
|
||||
nodes = set()
|
||||
for rnode in nameservers:
|
||||
if rnode.name == node.name:
|
||||
# We can't be primary and secondary at the same time
|
||||
continue
|
||||
|
||||
nodes.add(rnode.name)
|
||||
|
||||
return {
|
||||
'powerdns': {
|
||||
'my_secondary_servers': 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 {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue