An Ansible Role that manages Cloudflare DNS. Based on the cloudflare_dns, the official Ansible module.
- Existing Cloudflare Account.
- Access to the global API key of the Cloudflare account.
Available variables are listed below, along with default values (see defaults/main.yml
):
cloudflare_dns_account_email: average.joe@example.org
Cloudflare account email.
cloudflare_dns_account_api_token: 123abc456efg
Cloudflare account global API token.
cloudflare_dns_zone: example.org
Default target DNS zone.
cloudflare_dns_records:
- name: foo
value: 127.0.0.1
Use cloudflare_dns_records
to specify custom DNS records.
cloudflare_dns_records:
- name: foo
value: 127.0.0.1
zone: example.com
Use zone
to override the DNS zone for a particular DNS entry.
cloudflare_dns_records:
- name: foo
value: 127.0.0.1
state: absent
Add state: absent
to ensure a DNS record is removed.
cloudflare_dns_host_records:
- name: "{{ inventory_hostname }}"
value: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
DNS records for the inventory hosts are created automatically based on the template above.
cloudflare_dns_all_records: "{{ cloudflare_dns_host_records + cloudflare_dns_records }}"
All managed DNS records are combined within the cloudflare_dns_all_records
variable.
Tags can be used to limit the role execution to a particular task module. Following tags are available:
cloudflare_dns
,config
: Covers the full role lifecycle.
None.
- hosts: all
roles:
- nl2go.cloudflare_dns
Use docker-molecule following the instructions to run Molecule or install Molecule locally (not recommended, version conflicts might appear).
Provide Cloudflare API credentials using environment variables:
export CLOUDFLARE_DNS_ACCOUNT_EMAIL=average.joe@example.org
export CLOUDFLARE_DNS_ACCOUNT_API_TOKEN=123abc456efg
Use following to run tests:
molecule test --all
See the LICENSE.md file for details.
This role was created by in 2020 by Newsletter2Go GmbH.