From 074be924288a8b7d4551fcf64ab5b4eacd68a88d Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Mon, 20 Feb 2023 13:32:04 -0800 Subject: [PATCH 1/3] Add replace param to AutoArpa processor/provider --- docs/auto_arpa.md | 4 ++++ octodns/processor/arpa.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/auto_arpa.md b/docs/auto_arpa.md index a43f0d0..bf128f4 100644 --- a/docs/auto_arpa.md +++ b/docs/auto_arpa.md @@ -14,6 +14,10 @@ Alternatively the value can be a dictionary with configuration options for the A --- manager: auto_arpa: + # Replace duplicate records rather than throw an error, default is False + # which throws an error + replace: False + # Explicitly set the TTL of auto-created records, default is 3600s, 1hr ttl: 1800 ``` diff --git a/octodns/processor/arpa.py b/octodns/processor/arpa.py index 491a353..56522ac 100644 --- a/octodns/processor/arpa.py +++ b/octodns/processor/arpa.py @@ -11,10 +11,12 @@ from .base import BaseProcessor class AutoArpa(BaseProcessor): - def __init__(self, name, ttl=3600): + def __init__(self, name, ttl=3600, replace=False): super().__init__(name) self.log = getLogger(f'AutoArpa[{name}]') + self.log.info('__init__: ttl=%d, replace=%s', ttl, replace) self.ttl = ttl + self.replace = replace self._records = defaultdict(set) def process_source_zone(self, desired, sources): @@ -56,7 +58,7 @@ class AutoArpa(BaseProcessor): name, {'ttl': self.ttl, 'type': 'PTR', 'values': fqdns}, ) - zone.add_record(record) + zone.add_record(record, replace=self.replace) self.log.info( 'populate: found %s records', len(zone.records) - before From 3c2ad860f1639926b16f242b429d1c12931e17eb Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Mon, 20 Feb 2023 13:44:04 -0800 Subject: [PATCH 2/3] Address AutoArpa documenation comments from late review --- docs/auto_arpa.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/auto_arpa.md b/docs/auto_arpa.md index bf128f4..1942536 100644 --- a/docs/auto_arpa.md +++ b/docs/auto_arpa.md @@ -21,13 +21,21 @@ manager: ttl: 1800 ``` -Once enabled a singleton `AutoArpa` instance, `auto-arpa`, will be added to the pool of providers and globally configured to run as the very last global processor so that it will see all records as they will be seen by targets. Further all zones ending with `arpa.` will be held back and processed after all other zones have been completed so that all `A` and `AAAA` records will have been seen prior to planning the `arpa.` zones. +Once enabled a singleton `AutoArpa` instance, `auto-arpa`, will be added to the pool of providers and globally configured to run as the very last global processor so that it will see all records as they will be seen by targets. Further all zones ending with `arpa.` will be held back and processed after all other zones have been completed so that all `A` and `AAAA` records will have been seen prior to planning the `arpa.` zones. 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: - ... @@ -48,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 From c67d44fc8a1c78b9021572bb2fa037dc18d924fa Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Mon, 27 Feb 2023 09:12:21 -0800 Subject: [PATCH 3/3] AutoArpa.replace -> populate_should_replace to match YamlProvider --- docs/auto_arpa.md | 6 +++--- octodns/processor/arpa.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/auto_arpa.md b/docs/auto_arpa.md index 1942536..a8cb00a 100644 --- a/docs/auto_arpa.md +++ b/docs/auto_arpa.md @@ -14,9 +14,9 @@ Alternatively the value can be a dictionary with configuration options for the A --- manager: auto_arpa: - # Replace duplicate records rather than throw an error, default is False - # which throws an error - replace: False + # 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 ``` diff --git a/octodns/processor/arpa.py b/octodns/processor/arpa.py index 56522ac..f680d7b 100644 --- a/octodns/processor/arpa.py +++ b/octodns/processor/arpa.py @@ -11,12 +11,16 @@ from .base import BaseProcessor class AutoArpa(BaseProcessor): - def __init__(self, name, ttl=3600, replace=False): + 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, replace=%s', ttl, replace) + self.log.info( + '__init__: ttl=%d, populate_should_replace=%s', + ttl, + populate_should_replace, + ) self.ttl = ttl - self.replace = replace + self.populate_should_replace = populate_should_replace self._records = defaultdict(set) def process_source_zone(self, desired, sources): @@ -58,7 +62,7 @@ class AutoArpa(BaseProcessor): name, {'ttl': self.ttl, 'type': 'PTR', 'values': fqdns}, ) - zone.add_record(record, replace=self.replace) + zone.add_record(record, replace=self.populate_should_replace) self.log.info( 'populate: found %s records', len(zone.records) - before