Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v3.0
Documentation for other releases can be found by using the version selector in the top right of any doc page.cloudflare_dns
Manage DNS records on Cloudflare.
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| zone | true | string | The DNS zone to manage (e.g. example.com). | |
| record | string | The record name (e.g. www). Use “@” for the zone root. | ||
| type | string | A AAAA CNAME MX TXT SRV |
The DNS record type. | |
| value | string | The record value (required for state=present). | ||
| ttl | integer | The TTL in seconds. 1 means auto when proxied. | ||
| proxied | boolean | Whether the record is proxied through Cloudflare. | ||
| state | string | present absent |
The desired state of the record. | |
| api_token | string | Cloudflare API token. Falls back to CLOUDFLARE_API_TOKEN env var. | ||
| priority | integer | Priority for MX and SRV records. | ||
| weight | integer | Weight for SRV records. | ||
| port | integer | Port for SRV records. | ||
| validate_certs | boolean | Validate SSL certificates. |
Examples
- name: Create A record
cloudflare_dns:
zone: example.com
record: www
type: A
value: 192.168.1.1
ttl: 300
proxied: true
state: present
- name: Create AAAA record
cloudflare_dns:
zone: example.com
record: www
type: AAAA
value: 2001:db8::1
state: present
- name: Create CNAME record
cloudflare_dns:
zone: example.com
record: blog
type: CNAME
value: www.example.com
state: present
- name: Create MX record
cloudflare_dns:
zone: example.com
record: "@"
type: MX
value: mail.example.com
priority: 10
state: present
- name: Create TXT record
cloudflare_dns:
zone: example.com
record: "@"
type: TXT
value: "v=spf1 include:_spf.example.com ~all"
state: present
- name: Create SRV record
cloudflare_dns:
zone: example.com
record: "_sip._tcp"
type: SRV
value: "sip.example.com"
priority: 10
weight: 60
port: 5060
state: present
- name: Delete a DNS record
cloudflare_dns:
zone: example.com
record: old
type: A
state: absent
- name: Create record using API token from environment
cloudflare_dns:
zone: example.com
record: test
type: A
value: 10.0.0.1
state: present