ansible / ansible.builtin / v2.6.0 / module / cloudflare_dns manage Cloudflare DNS records | "added in version" 2.1 of ansible.builtin" Authors: Michael Gruener (@mgruener) preview | supported by communityansible.builtin.cloudflare_dns (v2.6.0) — module
pip
Install with pip install ansible==2.6.0
Manages dns records via the Cloudflare API, see the docs: U(https://api.cloudflare.com/)
# create a test.my.com A record to point to 127.0.0.1 - cloudflare_dns: zone: my.com record: test type: A value: 127.0.0.1 account_email: test@example.com account_api_token: dummyapitoken register: record
# create a my.com CNAME record to example.com - cloudflare_dns: zone: my.com type: CNAME value: example.com state: present account_email: test@example.com account_api_token: dummyapitoken
# change it's ttl - cloudflare_dns: zone: my.com type: CNAME value: example.com ttl: 600 state: present account_email: test@example.com account_api_token: dummyapitoken
# and delete the record - cloudflare_dns: zone: my.com type: CNAME value: example.com state: absent account_email: test@example.com account_api_token: dummyapitoken
# create a my.com CNAME record to example.com and proxy through cloudflare's network - cloudflare_dns: zone: my.com type: CNAME value: example.com state: present proxied: yes account_email: test@example.com account_api_token: dummyapitoken
# create TXT record "test.my.com" with value "unique value" # delete all other TXT records named "test.my.com" - cloudflare_dns: domain: my.com record: test type: TXT value: unique value state: present solo: true account_email: test@example.com account_api_token: dummyapitoken
# create a SRV record _foo._tcp.my.com - cloudflare_dns: domain: my.com service: foo proto: tcp port: 3500 priority: 10 weight: 20 type: SRV value: fooserver.my.com
ttl: default: 1 (automatic) description: - The TTL to give the new record. Must be between 120 and 2,147,483,647 seconds, or 1 for automatic. port: description: Service port. Required for C(type=SRV) solo: description: - Whether the record should be the only one for that record type and record name. Only use with C(state=present) - This will delete all other records with the same record name and type. type: choices: - A - AAAA - CNAME - TXT - SRV - MX - NS - SPF description: - The type of DNS record to create. Required if C(state=present) zone: aliases: - domain description: - The name of the Zone to work with (e.g. "example.com"). The Zone must already exist. required: true proto: description: - Service protocol. Required for C(type=SRV). - Common values are tcp and udp. - Before Ansible 2.6 only tcp and udp were available. state: choices: - present - absent default: present description: - Whether the record(s) should exist or not value: aliases: - content description: - The record value. Required for C(state=present) record: aliases: - name default: '@' description: - Record to add. Required if C(state=present). Default is C(@) (e.g. the zone name) weight: default: '1' description: Service weight. Required for C(type=SRV) proxied: default: 'no' description: Proxy through cloudflare network or just use DNS type: bool version_added: '2.3' version_added_collection: ansible.builtin service: description: Record service. Required for C(type=SRV) timeout: default: 30 description: - Timeout for Cloudflare API calls priority: default: '1' description: Record priority. Required for C(type=MX) and C(type=SRV) account_email: description: - Account email. required: true account_api_token: description: - 'Account API token. You can obtain your API key from the bottom of the Cloudflare ''My Account'' page, found here: U(https://www.cloudflare.com/a/account) ' required: true
record: contains: content: description: the record content (details depend on record type) returned: success sample: 192.0.2.91 type: string created_on: description: the record creation date returned: success sample: '2016-03-25T19:09:42.516553+00:00' type: string data: description: additional record data returned: success, if type is SRV sample: name: jabber port: 8080 priority: 10 proto: _tcp service: _xmpp target: jabberhost.sample.com weight: 5 type: dictionary id: description: the record id returned: success sample: f9efb0549e96abcb750de63b38c9576e type: string locked: description: No documentation available returned: success sample: false type: boolean meta: description: No documentation available returned: success sample: auto_added: false type: dictionary modified_on: description: record modification date returned: success sample: '2016-03-25T19:09:42.516553+00:00' type: string name: description: the record name as FQDN (including _service and _proto for SRV) returned: success sample: www.sample.com type: string 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: boolean proxied: description: whether the record is proxied through cloudflare returned: success sample: false type: boolean 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: string zone_id: description: the id of the zone containing the record returned: success sample: abcede0bf9f0066f94029d2e6b73856a type: string zone_name: description: the name of the zone containing the record returned: success sample: sample.com type: string description: dictionary containing the record data returned: success, except on record deletion type: complex