damex.cloudflare.cloudflare_dns_records role – Ensure Cloudflare DNS records.

Note

This role is part of the damex.cloudflare collection (version 1.2.3).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it use: ansible-galaxy collection install damex.cloudflare.

To use it in a playbook, specify: damex.cloudflare.cloudflare_dns_records.

Entry point main – Ensure Cloudflare DNS records.

Synopsis

  • Ensure Cloudflare DNS records.

Parameters

Parameter

Comments

cloudflare_dns_records_account_api_key

string

Cloudflare account API key.

cloudflare_dns_records_account_email

string

Cloudflare account email.

cloudflare_dns_records_api_token

string

Cloudflare API token.

cloudflare_dns_records_proxied

boolean

Default Cloudflare proxy status.

Choices:

  • false

  • true

cloudflare_dns_records_state

string

Default record state.

Choices:

  • "absent"

  • "present"

cloudflare_dns_records_ttl

integer

Default record TTL in seconds.

cloudflare_dns_records_zones

list / elements=dictionary / required

Zones with DNS records to ensure.

account_api_key

string

Cloudflare account API key.

account_email

string

Cloudflare account email.

api_token

string

Cloudflare API token.

name

string / required

Zone domain name.

records

list / elements=dictionary / required

DNS records to ensure.

content

string

Record content.

priority

integer

Record priority.

proxied

boolean

Cloudflare proxy status.

Choices:

  • false

  • true

record

string / required

DNS record name (subdomain or @ for zone apex).

state

string

Record state.

Choices:

  • "absent"

  • "present"

ttl

integer

Record TTL in seconds.

type

string / required

DNS record type.

Choices:

  • "A"

  • "AAAA"

  • "CAA"

  • "CNAME"

  • "DS"

  • "HTTPS"

  • "MX"

  • "NAPTR"

  • "NS"

  • "PTR"

  • "SMIMEA"

  • "SRV"

  • "SSHFP"

  • "SVCB"

  • "TLSA"

  • "TXT"

  • "URI"

Examples

- name: Ensure cloudflare DNS records
  hosts: all
  tasks:
    - name: Ensure cloudflare DNS records
      ansible.builtin.import_role:
        name: damex.cloudflare.cloudflare_dns_records
      vars:
        cloudflare_dns_records_api_token: "{{ cloudflare_api_token }}"
        cloudflare_dns_records_zones:
          - name: example.com
            records:
              - record: www
                type: A
                content: 192.0.2.1
              - record: example.com
                type: MX
                content: mail.example.com
                priority: 10
              - record: example.com
                type: TXT
                content: "v=spf1 include:_spf.example.com ~all"