From 8e5174ae44dca0e512c2937ffcd2778fe704dea2 Mon Sep 17 00:00:00 2001 From: missytake Date: Tue, 17 Dec 2024 20:33:07 +0100 Subject: [PATCH] DNS: add -all to cmdeploy dns --- cmdeploy/src/cmdeploy/cmdeploy.py | 8 +++++++- cmdeploy/src/cmdeploy/dns.py | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index b36b29f0..e53585ac 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -106,6 +106,12 @@ def dns_cmd_options(parser): default=None, help="write out a zonefile", ) + parser.add_argument( + "--all", + dest="all", + action="store_true", + help="check both required and recommended DNS records" + ) def dns_cmd(args, out): @@ -131,7 +137,7 @@ def dns_cmd(args, out): return 0 retcode = dns.check_full_zone( - sshexec, remote_data=remote_data, zonefile=zonefile, out=out + sshexec, remote_data=remote_data, zonefile=zonefile, out=out, all=args.all ) return retcode diff --git a/cmdeploy/src/cmdeploy/dns.py b/cmdeploy/src/cmdeploy/dns.py index a0606836..edf23067 100644 --- a/cmdeploy/src/cmdeploy/dns.py +++ b/cmdeploy/src/cmdeploy/dns.py @@ -40,7 +40,7 @@ def get_filled_zone_file(remote_data): return zonefile -def check_full_zone(sshexec, remote_data, out, zonefile) -> int: +def check_full_zone(sshexec, remote_data, out, zonefile, all) -> int: """Check existing DNS records, optionally write them to zone file and return (exitcode, remote_data) tuple.""" @@ -49,16 +49,18 @@ def check_full_zone(sshexec, remote_data, out, zonefile) -> int: kwargs=dict(zonefile=zonefile, mail_domain=remote_data["mail_domain"]), ) + returncode = 0 if required_diff: out.red("Please set required DNS entries at your DNS provider:\n") for line in required_diff: out(line) - return 1 - elif recommended_diff: + print() + returncode += 1 + if recommended_diff and (all or not required_diff): out("WARNING: these recommended DNS entries are not set:\n") for line in recommended_diff: out(line) - return 0 - out.green("Great! All your DNS entries are verified and correct.") - return 0 + if not (recommended_diff or required_diff): + out.green("Great! All your DNS entries are verified and correct.") + return returncode