From adda78b162bfb19c487623b14430a43487448f42 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 26 Feb 2023 14:13:47 +0100 Subject: [PATCH] [PR #5972/094dc6b6 backport][stable-5] cloudflare_dns: Fix setting SRV records with a root level entry (#6096) cloudflare_dns: Fix setting SRV records with a root level entry (#5972) * cloudflare_dns: Fix setting SRV records with a root level entry * cloudflare_dns: Remove the part which deletes the zone from the SRV record name The cloudflare API accepts the record name + zone name to be sent. Removing that, will guarantee the module to be idempotent even though that line was added ~7 years ago for that specific reason: https://github.com/ansible/ansible-modules-extras/commit/7477fe51418dbb890faba8966282ab83e597e6af It seems the most logical explanition is that Cloudflare changed their API response somewhere over the last 7 years. * cloudflare_dns: Update the changelog fragment (cherry picked from commit 094dc6b69c6ca4f54a261581962cdbf2956c0233) Co-authored-by: Roy Lenferink --- changelogs/fragments/5972-cloudflare-dns-srv-record.yml | 3 +++ plugins/modules/net_tools/cloudflare_dns.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/5972-cloudflare-dns-srv-record.yml diff --git a/changelogs/fragments/5972-cloudflare-dns-srv-record.yml b/changelogs/fragments/5972-cloudflare-dns-srv-record.yml new file mode 100644 index 0000000000..a331b49d23 --- /dev/null +++ b/changelogs/fragments/5972-cloudflare-dns-srv-record.yml @@ -0,0 +1,3 @@ +bugfixes: + - "cloudflare_dns - fixed the possiblity of setting a root-level SRV DNS record (https://github.com/ansible-collections/community.general/pull/5972)." + - "cloudflare_dns - fixed the idempotency for SRV DNS records (https://github.com/ansible-collections/community.general/pull/5972)." diff --git a/plugins/modules/net_tools/cloudflare_dns.py b/plugins/modules/net_tools/cloudflare_dns.py index 92132c0f6f..4514c78561 100644 --- a/plugins/modules/net_tools/cloudflare_dns.py +++ b/plugins/modules/net_tools/cloudflare_dns.py @@ -687,10 +687,11 @@ class CloudflareAPI(object): "port": params['port'], "weight": params['weight'], "priority": params['priority'], - "name": params['record'][:-len('.' + params['zone'])], + "name": params['record'], "proto": params['proto'], "service": params['service'] } + new_record = {"type": params['type'], "ttl": params['ttl'], 'data': srv_data} search_value = str(params['weight']) + '\t' + str(params['port']) + '\t' + params['value'] search_record = params['service'] + '.' + params['proto'] + '.' + params['record']