From 9f8dcecf63591c6a8a9c471746e06689c39ac221 Mon Sep 17 00:00:00 2001 From: Jeltz Date: Thu, 18 Aug 2022 16:35:16 +0200 Subject: [PATCH] dns_zone: ensure zone files are sorted --- library/dns_zone.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/dns_zone.py b/library/dns_zone.py index 58878e0..9b489a3 100755 --- a/library/dns_zone.py +++ b/library/dns_zone.py @@ -293,7 +293,9 @@ def make_records(args, ty): def zones_eq(lhs: dns.zone.Zone, rhs: dns.zone.Zone) -> bool: """Returns a `bool` indicating whether two `dns.zone.Zone`s are equal 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: @@ -365,7 +367,7 @@ def main() -> int: changed = current is None or not zones_eq(zone, current) 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)