dns_zone: ensure zone files are sorted

This commit is contained in:
jeltz 2022-08-18 16:35:16 +02:00
parent b9dd74af40
commit 9f8dcecf63
Signed by: jeltz
GPG key ID: 800882B66C0C3326

View file

@ -293,7 +293,9 @@ def make_records(args, ty):
def zones_eq(lhs: dns.zone.Zone, rhs: dns.zone.Zone) -> bool: def zones_eq(lhs: dns.zone.Zone, rhs: dns.zone.Zone) -> bool:
"""Returns a `bool` indicating whether two `dns.zone.Zone`s are equal """Returns a `bool` indicating whether two `dns.zone.Zone`s are equal
w.r.t. their text representation.""" w.r.t. their text representation."""
return lhs.to_text(relativize=False) == rhs.to_text(relativize=False) return lhs.to_text(relativize=False, sorted=True) == rhs.to_text(
relativize=False, sorted=True
)
def main() -> int: def main() -> int:
@ -365,7 +367,7 @@ def main() -> int:
changed = current is None or not zones_eq(zone, current) changed = current is None or not zones_eq(zone, current)
if changed: if changed:
zone.to_file(module.params["path"], relativize=False) zone.to_file(module.params["path"], relativize=True, sorted=True)
changed = module.set_fs_attributes_if_different(file_args, changed) changed = module.set_fs_attributes_if_different(file_args, changed)