From 274d7984c707c815c64fff8f1a179538016c9baa Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 07:34:31 +0200 Subject: [PATCH] [PR #10267/b7f9f24f backport][stable-11] cloudflare_dns: Add PTR record support (#10281) cloudflare_dns: Add PTR record support (#10267) * cloudflare_dns: Add PTR record support * Add changelog fragment * Apply suggestions from code review --------- (cherry picked from commit b7f9f24ffe99109a5f869dbb2e1539a241abac69) Co-authored-by: Titus Sanchez Co-authored-by: Felix Fontein --- .../10267-add-cloudflare-ptr-record-support.yml | 2 ++ plugins/modules/cloudflare_dns.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/10267-add-cloudflare-ptr-record-support.yml diff --git a/changelogs/fragments/10267-add-cloudflare-ptr-record-support.yml b/changelogs/fragments/10267-add-cloudflare-ptr-record-support.yml new file mode 100644 index 0000000000..29d71ca393 --- /dev/null +++ b/changelogs/fragments/10267-add-cloudflare-ptr-record-support.yml @@ -0,0 +1,2 @@ +minor_changes: + - cloudflare_dns - adds support for PTR records (https://github.com/ansible-collections/community.general/pull/10267). diff --git a/plugins/modules/cloudflare_dns.py b/plugins/modules/cloudflare_dns.py index 0fd0f5ffcc..002bb2c3e1 100644 --- a/plugins/modules/cloudflare_dns.py +++ b/plugins/modules/cloudflare_dns.py @@ -156,9 +156,10 @@ options: description: - The type of DNS record to create. Required if O(state=present). - Support for V(SPF) has been removed from community.general 9.0.0 since that record type is no longer supported by + - Support for V(PTR) has been added in community.general 11.1.0. CloudFlare. type: str - choices: [A, AAAA, CNAME, DS, MX, NS, SRV, SSHFP, TLSA, CAA, TXT] + choices: [A, AAAA, CNAME, DS, MX, NS, SRV, SSHFP, TLSA, CAA, TXT, PTR] value: description: - The record value. @@ -311,6 +312,14 @@ EXAMPLES = r""" algorithm: 8 hash_type: 2 value: B4EB5AC4467D2DFB3BAF9FB9961DC1B6FED54A58CDFAA3E465081EC86F89BFAB + +- name: Create PTR record "1.2.0.192.in-addr.arpa" with value "test.example.com" + community.general.cloudflare_dns: + zone: 2.0.192.in-addr.arpa + record: 1 + type: PTR + value: test.example.com + state: present """ RETURN = r""" @@ -729,7 +738,7 @@ class CloudflareAPI(object): if (params['type'] is None) or (params['record'] is None): self.module.fail_json(msg="You must provide a type and a record to create a new record") - if (params['type'] in ['A', 'AAAA', 'CNAME', 'TXT', 'MX', 'NS']): + if (params['type'] in ['A', 'AAAA', 'CNAME', 'TXT', 'MX', 'NS', 'PTR']): if not params['value']: self.module.fail_json(msg="You must provide a non-empty value to create this record type") @@ -935,7 +944,7 @@ def main(): state=dict(type='str', default='present', choices=['absent', 'present']), timeout=dict(type='int', default=30), ttl=dict(type='int', default=1), - type=dict(type='str', choices=['A', 'AAAA', 'CNAME', 'DS', 'MX', 'NS', 'SRV', 'SSHFP', 'TLSA', 'CAA', 'TXT']), + type=dict(type='str', choices=['A', 'AAAA', 'CNAME', 'DS', 'MX', 'NS', 'SRV', 'SSHFP', 'TLSA', 'CAA', 'TXT', 'PTR']), value=dict(type='str', aliases=['content']), weight=dict(type='int', default=1), zone=dict(type='str', required=True, aliases=['domain']),