community / community.general / 8.5.0 / module / cloudflare_dns Manage Cloudflare DNS records Authors: Michael Gruener (@mgruener)community.general.cloudflare_dns (8.5.0) — module
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
Manages dns records via the Cloudflare API, see the docs: U(https://api.cloudflare.com/).
- name: Create a test.example.net A record to point to 127.0.0.1 community.general.cloudflare_dns: zone: example.net record: test type: A value: 127.0.0.1 account_email: test@example.com account_api_key: dummyapitoken register: record
- name: Create a record using api token community.general.cloudflare_dns: zone: example.net record: test type: A value: 127.0.0.1 api_token: dummyapitoken
- name: Create a example.net CNAME record to example.com community.general.cloudflare_dns: zone: example.net type: CNAME value: example.com account_email: test@example.com account_api_key: dummyapitoken state: present
- name: Change its TTL community.general.cloudflare_dns: zone: example.net type: CNAME value: example.com ttl: 600 account_email: test@example.com account_api_key: dummyapitoken state: present
- name: Delete the record community.general.cloudflare_dns: zone: example.net type: CNAME value: example.com account_email: test@example.com account_api_key: dummyapitoken state: absent
- name: Create a example.net CNAME record to example.com and proxy through Cloudflare's network community.general.cloudflare_dns: zone: example.net type: CNAME value: example.com proxied: true account_email: test@example.com account_api_key: dummyapitoken state: present
# This deletes all other TXT records named "test.example.net" - name: Create TXT record "test.example.net" with value "unique value" community.general.cloudflare_dns: domain: example.net record: test type: TXT value: unique value solo: true account_email: test@example.com account_api_key: dummyapitoken state: present
- name: Create an SRV record _foo._tcp.example.net community.general.cloudflare_dns: domain: example.net service: foo proto: tcp port: 3500 priority: 10 weight: 20 type: SRV value: fooserver.example.net
- name: Create a SSHFP record login.example.com community.general.cloudflare_dns: zone: example.com record: login type: SSHFP algorithm: 4 hash_type: 2 value: 9dc1d6742696d2f51ca1f1a78b3d16a840f7d111eb9454239e70db31363f33e1
- name: Create a TLSA record _25._tcp.mail.example.com community.general.cloudflare_dns: zone: example.com record: mail port: 25 proto: tcp type: TLSA cert_usage: 3 selector: 1 hash_type: 1 value: 6b76d034492b493e15a7376fccd08e63befdad0edab8e442562f532338364bf3
- name: Create a CAA record subdomain.example.com community.general.cloudflare_dns: zone: example.com record: subdomain type: CAA flag: 0 tag: issue value: ca.example.com
- name: Create a DS record for subdomain.example.com community.general.cloudflare_dns: zone: example.com record: subdomain type: DS key_tag: 5464 algorithm: 8 hash_type: 2 value: B4EB5AC4467D2DFB3BAF9FB9961DC1B6FED54A58CDFAA3E465081EC86F89BFAB
tag: choices: - issue - issuewild - iodef description: - CAA issue restriction. - Required for O(type=CAA) when O(state=present). type: str version_added: 8.0.0 version_added_collection: community.general ttl: default: 1 description: - The TTL to give the new record. - Must be between 120 and 2,147,483,647 seconds, or 1 for automatic. type: int flag: choices: - 0 - 1 description: - Issuer Critical Flag. - Required for O(type=CAA) when O(state=present). type: int version_added: 8.0.0 version_added_collection: community.general port: description: - Service port. - Required for O(type=SRV) and O(type=TLSA). type: int solo: description: - Whether the record should be the only one for that record type and record name. - Only use with O(state=present). - This will delete all other records with the same record name and type. type: bool type: choices: - A - AAAA - CNAME - DS - MX - NS - SPF - SRV - SSHFP - TLSA - CAA - TXT description: - The type of DNS record to create. Required if O(state=present). - Note that V(SPF) is no longer supported by CloudFlare. Support for it will be removed from community.general 9.0.0. type: str zone: aliases: - domain description: - The name of the Zone to work with (e.g. "example.com"). - The Zone must already exist. required: true type: str proto: description: - Service protocol. Required for O(type=SRV) and O(type=TLSA). - Common values are TCP and UDP. type: str state: choices: - absent - present default: present description: - Whether the record(s) should exist or not. type: str value: aliases: - content description: - The record value. - Required for O(state=present). type: str record: aliases: - name default: '@' description: - Record to add. - Required if O(state=present). - Default is V(@) (that is, the zone name). type: str weight: default: 1 description: - Service weight. - Required for O(type=SRV). type: int key_tag: description: - DNSSEC key tag. - Needed for O(type=DS) when O(state=present). type: int proxied: default: false description: - Proxy through Cloudflare network or just use DNS. type: bool service: description: - Record service. - Required for O(type=SRV). type: str timeout: default: 30 description: - Timeout for Cloudflare API calls. type: int priority: default: 1 description: - Record priority. - Required for O(type=MX) and O(type=SRV) type: int selector: choices: - 0 - 1 description: - Selector number. - Required for O(type=TLSA) when O(state=present). type: int algorithm: description: - Algorithm number. - Required for O(type=DS) and O(type=SSHFP) when O(state=present). type: int api_token: description: - API token. - Required for api token authentication. - 'You can obtain your API token from the bottom of the Cloudflare ''My Account'' page, found here: U(https://dash.cloudflare.com/).' - Can be specified in E(CLOUDFLARE_TOKEN) environment variable since community.general 2.0.0. required: false type: str version_added: 0.2.0 version_added_collection: community.general hash_type: choices: - 1 - 2 description: - Hash type number. - Required for O(type=DS), O(type=SSHFP) and O(type=TLSA) when O(state=present). type: int cert_usage: choices: - 0 - 1 - 2 - 3 description: - Certificate usage number. - Required for O(type=TLSA) when O(state=present). type: int account_email: description: - Account email. Required for API keys authentication. required: false type: str account_api_key: aliases: - account_api_token description: - Account API key. - Required for api keys authentication. - 'You can obtain your API key from the bottom of the Cloudflare ''My Account'' page, found here: U(https://dash.cloudflare.com/).' required: false type: str
record: contains: content: description: The record content (details depend on record type). returned: success sample: 192.0.2.91 type: str created_on: description: The record creation date. returned: success sample: '2016-03-25T19:09:42.516553Z' type: str data: description: Additional record data. returned: success, if type is SRV, DS, SSHFP TLSA or CAA sample: name: jabber port: 8080 priority: 10 proto: _tcp service: _xmpp target: jabberhost.sample.com weight: 5 type: dict id: description: The record ID. returned: success sample: f9efb0549e96abcb750de63b38c9576e type: str locked: description: No documentation available. returned: success sample: false type: bool meta: description: No documentation available. returned: success sample: auto_added: false type: dict modified_on: description: Record modification date. returned: success sample: '2016-03-25T19:09:42.516553Z' type: str name: description: The record name as FQDN (including _service and _proto for SRV). returned: success sample: www.sample.com type: str priority: description: Priority of the MX record. returned: success, if type is MX sample: 10 type: int proxiable: description: Whether this record can be proxied through Cloudflare. returned: success sample: false type: bool proxied: description: Whether the record is proxied through Cloudflare. returned: success sample: false type: bool ttl: description: The time-to-live for the record. returned: success sample: 300 type: int type: description: The record type. returned: success sample: A type: str zone_id: description: The ID of the zone containing the record. returned: success sample: abcede0bf9f0066f94029d2e6b73856a type: str zone_name: description: The name of the zone containing the record. returned: success sample: sample.com type: str description: A dictionary containing the record data. returned: success, except on record deletion type: complex