Skip to content
Snippets Groups Projects
Commit c8eb6d74 authored by Thomas Woerner's avatar Thomas Woerner
Browse files

host: Fix DNS resource record not found error

The "DNS resource record not found" error occurs when a host arecord
or aaaarecord member is ensured to be absent and no dnsrecord entry
for the host exists.

The arecord or aaaarecord item are removed from dnsrecord_args if the
record is not defined in res_find_dnsrecord.
parent fe7929cd
No related branches found
No related tags found
No related merge requests found
...@@ -1327,6 +1327,23 @@ def main(): ...@@ -1327,6 +1327,23 @@ def main():
dnsrecord_args = gen_dnsrecord_args(ansible_module, dnsrecord_args = gen_dnsrecord_args(ansible_module,
ip_address, reverse) ip_address, reverse)
# Remove arecord and aaaarecord from dnsrecord_args
# if the record does not exits in res_find_dnsrecord
# to prevent "DNS resource record not found" error
if "arecord" in dnsrecord_args \
and dnsrecord_args["arecord"] is not None \
and len(dnsrecord_args["arecord"]) > 0 \
and (res_find_dnsrecord is None
or "arecord" not in res_find_dnsrecord):
del dnsrecord_args["arecord"]
if "aaaarecord" in dnsrecord_args \
and dnsrecord_args["aaaarecord"] is not None \
and len(dnsrecord_args["aaaarecord"]) > 0 \
and (res_find_dnsrecord is None
or "aaaarecord" not in res_find_dnsrecord):
del dnsrecord_args["aaaarecord"]
if "arecord" in dnsrecord_args or \ if "arecord" in dnsrecord_args or \
"aaaarecord" in dnsrecord_args: "aaaarecord" in dnsrecord_args:
domain_name = name[name.find(".")+1:] domain_name = name[name.find(".")+1:]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment