DNS: add -all to cmdeploy dns

This commit is contained in:
missytake
2024-12-17 20:33:07 +01:00
parent 69fe5eac2b
commit 8e5174ae44
2 changed files with 15 additions and 7 deletions

View File

@@ -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

View File

@@ -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