Skip to content

Commit

Permalink
[PR #5972/094dc6b6 backport][stable-6] cloudflare_dns: Fix setting SR…
Browse files Browse the repository at this point in the history
…V records with a root level entry (#6097)

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: ansible/ansible-modules-extras@7477fe5

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 094dc6b)

Co-authored-by: Roy Lenferink <lenferinkroy@gmail.com>
  • Loading branch information
patchback[bot] and rlenferink authored Feb 26, 2023
1 parent bc64c40 commit 31eddc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/5972-cloudflare-dns-srv-record.yml
Original file line number Diff line number Diff line change
@@ -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)."
3 changes: 2 additions & 1 deletion plugins/modules/cloudflare_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,11 @@ def ensure_dns_record(self, **kwargs):
"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']
Expand Down

0 comments on commit 31eddc0

Please sign in to comment.