bundlewrap/bundles/bind/metadata.py
mwiegand 181d187baf wip
2021-06-20 11:51:39 +02:00

48 lines
1.1 KiB
Python

defaults = {
'apt': {
'packages': {
'bind9': {},
},
},
'bind': {
'zones': {},
},
}
@metadata_reactor.provides(
'bind/zones',
)
def collect_records(metadata):
zones = metadata.get('bind/zones')
for other_node in repo.nodes:
for fqdn, records in other_node.metadata.get('dns').items():
matching_zones = sorted(
filter(
lambda potential_zone: fqdn.endswith(potential_zone),
zones
),
key=len,
)
if matching_zones:
zone = matching_zones[0]
else:
continue
name = fqdn[0:-len(zone) - 1]
for type, values in records.items():
for value in values:
zones\
.setdefault(zone, [])\
.append(
{'name': name, 'type': type, 'value': value}
)
return {
'bind': {
'zones': zones,
},
}