1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Merge remote-tracking branch 'origin/main' into je/arpa-matching-fix

This commit is contained in:
Ross McFarland
2023-02-27 09:58:31 -08:00
2 changed files with 27 additions and 10 deletions

View File

@@ -14,6 +14,10 @@ Alternatively the value can be a dictionary with configuration options for the A
---
manager:
auto_arpa:
# Whether duplicate records should replace rather than error
# (optiona, default False)
populate_should_replace: false
# Explicitly set the TTL of auto-created records, default is 3600s, 1hr
ttl: 1800
```
@@ -22,8 +26,16 @@ Once enabled a singleton `AutoArpa` instance, `auto-arpa`, will be added to the
In order to add `PTR` records for a zone the `auto-arpa` source should be added to the list of sources for the zone.
```yaml
# Zones are matched on suffix so `0.10.in-addr.arpa.` would match anything
# under `10.0/16` or `0.8.e.f.ip6-.arpa.` would match any IPv6 address under
# `fe80::`, 0.0.10 here matches 10.0.0/24.
0.0.10.in-addr.arpa.:
sources:
# In most cases you'll have some statically configured records combined in
# with the auto-generated records as shown here, but that's not strictly
# required and this could just be `auto-arpa`.
# would throw an DuplicateRecordException.
- config
- auto-arpa
targets:
- ...
@@ -44,24 +56,23 @@ providers:
class: octodns.provider.yaml.YamlProvider
directory: tests/config
powerdns:
class: octodns_powerdns.PowerDnsProvider
host: 10.0.0.53
port: 8081
api_key: env/POWERDNS_API_KEY
route53:
class: octodns_route53.Route53Provider
access_key_id: env/AWS_ACCESS_KEY_ID
secret_access_key: env/AWS_SECRET_ACCESS_KEY
zones:
exxampled.com.:
sources:
- config
targets:
- powerdns
- route53
0.0.10.in-addr.arpa.:
sources:
- auto-arpa
targets:
- powerdns
- route53
```
#### config/exxampled.com.yaml

View File

@@ -11,10 +11,16 @@ from .base import BaseProcessor
class AutoArpa(BaseProcessor):
def __init__(self, name, ttl=3600):
def __init__(self, name, ttl=3600, populate_should_replace=False):
super().__init__(name)
self.log = getLogger(f'AutoArpa[{name}]')
self.log.info(
'__init__: ttl=%d, populate_should_replace=%s',
ttl,
populate_should_replace,
)
self.ttl = ttl
self.populate_should_replace = populate_should_replace
self._records = defaultdict(set)
def process_source_zone(self, desired, sources):
@@ -56,7 +62,7 @@ class AutoArpa(BaseProcessor):
name,
{'ttl': self.ttl, 'type': 'PTR', 'values': fqdns},
)
zone.add_record(record)
zone.add_record(record, replace=self.populate_should_replace)
self.log.info(
'populate: found %s records', len(zone.records) - before