diff --git a/projects/public-dns/src/python/arrdem/updater/__main__.py b/projects/public-dns/src/python/arrdem/updater/__main__.py index f95c31d..984e26c 100644 --- a/projects/public-dns/src/python/arrdem/updater/__main__.py +++ b/projects/public-dns/src/python/arrdem/updater/__main__.py @@ -54,10 +54,13 @@ def records_equate(lr, rr): if not same_record(lr, rr): return False + elif lr["rrset_ttl"] != rr["rrset_ttl"]: return False + elif set(lr["rrset_values"]) != set(rr["rrset_values"]): return False + else: return True @@ -100,28 +103,18 @@ def diff_zones(left_zone, right_zone): """ in_left_not_right = [] + in_right_not_left = [] for lr in left_zone: flag = False for rr in right_zone: - if same_record(lr, rr) and records_equate(lr, rr): - flag = True - break + if records_equate(lr, rr): + flag |= True if not flag: in_left_not_right.append(lr) + in_right_not_left.append(rr) - in_right_not_left = [] - for rr in right_zone: - flag = False - for lr in left_zone: - if same_record(lr, rr) and records_equate(lr, rr): - flag = True - break - - if not flag: - in_right_not_left.append(lr) - - return in_left_not_right or in_right_not_left + return in_left_not_right, in_right_not_left parser = argparse.ArgumentParser( @@ -157,6 +150,8 @@ def main(): **config["bindings"], } + print(f"Using config {template_bindings!r}...") + api = GandiAPI(config["gandi"]["key"]) for task in config["tasks"]: @@ -167,13 +162,26 @@ def main(): os.path.join(args.template_dir, task["template"]), template_bindings ) + print(f"Running task {task!r}...") + for zone_name in task["zones"] or []: try: live_zone = api.domain_records(zone_name) - if diff_zones(computed_zone, live_zone): - print("Zone {} differs, computed zone:".format(zone_name)) + lr, rl = diff_zones(computed_zone, live_zone) + if lr or rl: + print(f"Zone {zone_name} differs;") + print("Computed:") pprint(computed_zone) + pprint("Live:") + pprint(live_zone) + if(rl): + print("Live records not recomputed") + pprint(rl) + if(lr): + print("New records not live") + pprint(lr) + if not args.dry: print(api.replace_domain(zone_name, computed_zone)) else: diff --git a/projects/public-dns/src/resources/zonefiles/tirefireind.us.j2 b/projects/public-dns/src/resources/zonefiles/tirefireind.us.j2 index 5f452e0..9a52434 100644 --- a/projects/public-dns/src/resources/zonefiles/tirefireind.us.j2 +++ b/projects/public-dns/src/resources/zonefiles/tirefireind.us.j2 @@ -7,7 +7,7 @@ fm1._domainkey {{ ttl }} IN CNAME fm1.tirefireind.us.dkim.fmhosted.com. fm2._domainkey {{ ttl }} IN CNAME fm2.tirefireind.us.dkim.fmhosted.com. fm3._domainkey {{ ttl }} IN CNAME fm3.tirefireind.us.dkim.fmhosted.com. -@ {{ ttl }} IN TXT v=spf1 include:spf.messagingengine.com ?all +@ {{ ttl }} IN TXT "v=spf1 include:spf.messagingengine.com ?all" # Core records {% for link in local.public_v4s %} @@ -20,9 +20,6 @@ feed {{ ttl }} IN A {{ link }} ton {{ ttl }} IN A {{ link }} {% endfor %} -# Gitlab -gitlab {{ ttl }} IN A {{ sroo.public_v4 }} - # Host records ## The hand-rolled hosts feed.h.dia0.site {{ ttl }} IN A 10.0.0.5