damex.cloudflare.cloudflare_dns_record module – Ensure Cloudflare DNS record
Note
This module 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_record.
Synopsis
Ensures Cloudflare DNS records using the Cloudflare API, see the docs: https://developers.cloudflare.com/dns/.
Records are matched by type, name, and content for idempotency.
Parameters
Parameter |
Comments |
|---|---|
Cloudflare account API key. Required together with |
|
Cloudflare account email. Required together with |
|
Cloudflare API token. Required if Can be specified in |
|
DNS record content. Required when |
|
DNS record priority. Required for MX and URI records. |
|
Cloudflare proxy status. Only applicable to A, AAAA, and CNAME records. Choices:
|
|
DNS record name (subdomain or @ for zone apex). |
|
DNS record state. Choices:
|
|
DNS record TTL in seconds. Value of 1 means automatic. Default: |
|
DNS record type. Choices:
|
|
Zone identifier. Required if |
|
Zone domain name. Required if Resolved to zone identifier via the Cloudflare API. |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Supports check mode. |
|
Support: full |
Supports diff mode. |
Examples
- name: Ensure A record
damex.cloudflare.cloudflare_dns_record:
zone_name: example.com
api_token: "{{ cloudflare_api_token }}"
record: www
type: A
content: 192.0.2.1
- name: Ensure AAAA record
damex.cloudflare.cloudflare_dns_record:
zone_name: example.com
api_token: "{{ cloudflare_api_token }}"
record: www
type: AAAA
content: 2001:db8::1
- name: Ensure MX record
damex.cloudflare.cloudflare_dns_record:
zone_name: example.com
api_token: "{{ cloudflare_api_token }}"
record: example.com
type: MX
content: mail.example.com
priority: 10
- name: Ensure CNAME record with proxy
damex.cloudflare.cloudflare_dns_record:
zone_name: example.com
api_token: "{{ cloudflare_api_token }}"
record: blog
type: CNAME
content: example.com
proxied: true
- name: Ensure TXT record
damex.cloudflare.cloudflare_dns_record:
zone_name: example.com
api_token: "{{ cloudflare_api_token }}"
record: example.com
type: TXT
content: v=spf1 include:_spf.example.com ~all
- name: Ensure DNS record is absent
damex.cloudflare.cloudflare_dns_record:
zone_name: example.com
api_token: "{{ cloudflare_api_token }}"
record: old
type: A
content: 192.0.2.99
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
DNS record object from the Cloudflare API. Returned: when state is present |
|
Record content. Returned: success |
|
Record identifier. Returned: success |
|
Record name. Returned: success |
|
Record priority. Returned: success |
|
Proxy status. Returned: success |
|
Record TTL. Returned: success |
|
Record type. Returned: success |