From 2bd44584d3bac200a7fcb9b35544c8c6324b34f0 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 18 Oct 2025 20:43:46 +1300 Subject: [PATCH] cloudflare_dns: rollback validation for SRV records (#10937) * cloudflare_dns: rollback validation for SRV records * add changelog frag --- changelogs/fragments/10934-cloudflare-dns-srv-bug.yml | 2 ++ plugins/modules/cloudflare_dns.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/10934-cloudflare-dns-srv-bug.yml diff --git a/changelogs/fragments/10934-cloudflare-dns-srv-bug.yml b/changelogs/fragments/10934-cloudflare-dns-srv-bug.yml new file mode 100644 index 0000000000..eb2b06d2f1 --- /dev/null +++ b/changelogs/fragments/10934-cloudflare-dns-srv-bug.yml @@ -0,0 +1,2 @@ +bugfixes: + - cloudflare_dns - roll back changes to SRV record validation (https://github.com/ansible-collections/community.general/issues/10934, https://github.com/ansible-collections/community.general/pull/10937). diff --git a/plugins/modules/cloudflare_dns.py b/plugins/modules/cloudflare_dns.py index abed0023f8..df10d0a0b6 100644 --- a/plugins/modules/cloudflare_dns.py +++ b/plugins/modules/cloudflare_dns.py @@ -927,7 +927,7 @@ def main(): required_if=[ ('state', 'present', ['record', 'type', 'value']), ('state', 'absent', ['record']), - ('type', 'SRV', ['proto', 'service', 'value']), + ('type', 'SRV', ['proto', 'service']), ('type', 'TLSA', ['proto', 'port']), ('type', 'CAA', ['flag', 'tag', 'value']), ], @@ -940,8 +940,11 @@ def main(): ) if module.params['type'] == 'SRV': - if not module.params['value'] == '': - module.fail_json(msg="For SRV records the params weight, port and value all need to be defined.") + if not ((module.params['weight'] is not None and module.params['port'] is not None + and not (module.params['value'] is None or module.params['value'] == '')) + or (module.params['weight'] is None and module.params['port'] is None + and (module.params['value'] is None or module.params['value'] == ''))): + module.fail_json(msg="For SRV records the params weight, port and value all need to be defined, or not at all.") if module.params['type'] == 'SSHFP': if not ((module.params['algorithm'] is not None and module.params['hash_type'] is not None