Add integration tests for the cloudflare_dns module

This commit is contained in:
Michael Gruener 2016-03-23 21:41:50 +01:00
parent 81d9066ee1
commit 94806e1953
13 changed files with 1593 additions and 0 deletions

View file

@ -227,6 +227,11 @@ cloudstack:
RC=$$? ; \
exit $$RC;
cloudflare: $(CREDENTIALS_FILE)
ansible-playbook cloudflare.yml -i $(INVENTORY) -e @$(VARS_FILE) -e @$(CREDENTIALS_FILE) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
RC=$$? ; \
exit $$RC;
$(CONSUL_RUNNING):
consul:

View file

@ -0,0 +1,8 @@
---
- hosts: localhost
connection: local
gather_facts: no
tags:
- cloudflare
roles:
- { role: test_cloudflare_dns, tags: test_cloudflare_dns }

View file

@ -19,3 +19,8 @@ azure_cert_path: "{{ lookup('env', 'AZURE_CERT_PATH') }}"
# GITHUB SSH private key - a path to a SSH private key for use with github.com
github_ssh_private_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa"
# Cloudflare Credentials
cloudflare_api_token:
cloudflare_email:
cloudflare_zone:

View file

@ -0,0 +1,2 @@
---
cloudflare_dns_record: "{{ resource_prefix|lower }}"

View file

@ -0,0 +1,180 @@
---
######## A record tests #################
- name: "Test: A record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.0.1
ttl: 150
register: cloudflare_dns
- name: "Validate: A record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '127.0.0.1'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'A'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: A record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.0.1
ttl: 150
register: cloudflare_dns
- name: "Validate: A record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: A record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.0.1
ttl: 300
register: cloudflare_dns
- name: "Validate: A record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- name: "Test: A record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.1.1
ttl: 150
register: cloudflare_dns
- name: "Validate: A record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '127.0.1.1'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'A'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: A record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.0.1
ttl: 300
register: cloudflare_dns
- name: "Validate: A record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == '127.0.0.1'
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.type == 'A'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: A record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.1.1
ttl: 150
solo: true
register: cloudflare_dns
- name: "Validate: A record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '127.0.1.1'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'A'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: A record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.0.1
ttl: 300
state: absent
register: cloudflare_dns
- name: "Validate: A record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: A record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.1.1
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: A record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: A record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: A
value: 127.0.1.1
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: A record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,180 @@
---
######## AAAA record tests #################
- name: "Test: AAAA record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::1"
ttl: 150
register: cloudflare_dns
- name: "Validate: AAAA record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '::1'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'AAAA'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: AAAA record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::1"
ttl: 150
register: cloudflare_dns
- name: "Validate: AAAA record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: AAAA record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::1"
ttl: 300
register: cloudflare_dns
- name: "Validate: AAAA record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- name: "Test: AAAA record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::2"
ttl: 150
register: cloudflare_dns
- name: "Validate: AAAA record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '::2'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'AAAA'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: AAAA record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::1"
ttl: 300
register: cloudflare_dns
- name: "Validate: AAAA record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == '::1'
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.type == 'AAAA'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: AAAA record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::2"
ttl: 150
solo: true
register: cloudflare_dns
- name: "Validate: AAAA record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '::2'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'AAAA'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: AAAA record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::1"
ttl: 300
state: absent
register: cloudflare_dns
- name: "Validate: AAAA record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: AAAA record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::2"
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: AAAA record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: AAAA record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: AAAA
value: "::2"
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: AAAA record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,139 @@
---
######## CNAME record tests #################
# the '.' at the end of the value is intentional
# it must be verified that the '.' will be stripped
- name: "Test: CNAME record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv1.{{ cloudflare_zone }}."
ttl: 150
register: cloudflare_dns
- name: "Validate: CNAME record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == "srv1.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'CNAME'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: CNAME record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv1.{{ cloudflare_zone }}."
ttl: 150
register: cloudflare_dns
- name: "Validate: CNAME record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: CNAME record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv2.{{ cloudflare_zone }}"
ttl: 300
register: cloudflare_dns
- name: "Validate: CNAME record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == "srv2.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.ttl == 300
- name: "Test: CNAME record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv3.{{ cloudflare_zone }}"
ttl: 600
solo: true
register: cloudflare_dns
- name: "Validate: CNAME record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == "srv3.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.ttl == 600
- cloudflare_dns.result.record.type == 'CNAME'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: CNAME record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv2.{{ cloudflare_zone }}"
ttl: 300
state: absent
register: cloudflare_dns
- name: "Validate: CNAME record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: CNAME record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv3.{{ cloudflare_zone }}"
ttl: 600
state: absent
register: cloudflare_dns
- name: "Validate: CNAME record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: CNAME record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: CNAME
value: "srv3.{{ cloudflare_zone }}"
ttl: 600
state: absent
register: cloudflare_dns
- name: "Validate: CNAME record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,64 @@
---
- name: "Test: no args"
cloudflare_dns:
ignore_errors: true
register: cloudflare_dns
- name: "Validate: no args"
assert:
that:
- cloudflare_dns|failed
- "cloudflare_dns.msg.find('missing required arguments: ') != -1"
- name: "Test: only credentials"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
ignore_errors: true
register: cloudflare_dns
- name: "Validate: only credentials"
assert:
that:
- cloudflare_dns|failed
- "cloudflare_dns.msg.find('missing required arguments: ') != -1"
- name: "Test: credentials and zone"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
ignore_errors: true
register: cloudflare_dns
- name: "Validate: credentials and zone"
assert:
that:
- cloudflare_dns|failed
- "cloudflare_dns.msg.find('but the following are missing: ') != -1"
- name: "Test: credentials, zone and type"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
type: TXT
ignore_errors: true
register: cloudflare_dns
- name: "Validate: credentials, zone and type"
assert:
that:
- cloudflare_dns|failed
- "cloudflare_dns.msg.find('but the following are missing: ') != -1"
######## record tests #################
- include: a_record.yml
- include: aaaa_record.yml
- include: cname_record.yml
- include: txt_record.yml
- include: ns_record.yml
- include: spf_record.yml
- include: mx_record.yml
- include: srv_record.yml

View file

@ -0,0 +1,194 @@
---
######## MX record tests #################
- name: "Test: MX record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}."
ttl: 150
priority: 20
register: cloudflare_dns
- name: "Validate: MX record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.priority == 20
- cloudflare_dns.result.record.type == 'MX'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: MX record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}."
ttl: 150
priority: 20
register: cloudflare_dns
- name: "Validate: MX record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: MX record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 300
priority: 10
register: cloudflare_dns
- name: "Validate: MX record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.priority == 10
- name: "Test: MX record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx2-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
register: cloudflare_dns
- name: "Validate: MX record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'mx2-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.priority == 30
- cloudflare_dns.result.record.type == 'MX'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: MX record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 300
priority: 10
register: cloudflare_dns
- name: "Validate: MX record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.priority == 10
- cloudflare_dns.result.record.type == 'MX'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: MX record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx2-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
solo: true
register: cloudflare_dns
- name: "Validate: MX record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'mx2-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.priority == 30
- cloudflare_dns.result.record.type == 'MX'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: MX record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx1-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 300
priority: 10
state: absent
register: cloudflare_dns
- name: "Validate: MX record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: MX record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx2-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
state: absent
register: cloudflare_dns
- name: "Validate: MX record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: MX record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: MX
value: "mx2-{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
state: absent
register: cloudflare_dns
- name: "Validate: MX record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,182 @@
---
######## NS record tests #################
# the '.' at the end of the value is intentional
# it must be verified that the '.' will be stripped
- name: "Test: NS record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: an.si.ble.
ttl: 150
register: cloudflare_dns
- name: "Validate: NS record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'an.si.ble'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'NS'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: NS record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: an.si.ble.
ttl: 150
register: cloudflare_dns
- name: "Validate: NS record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: NS record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: an.si.ble
ttl: 300
register: cloudflare_dns
- name: "Validate: NS record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- name: "Test: NS record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: ble.si.an
ttl: 150
register: cloudflare_dns
- name: "Validate: NS record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'ble.si.an'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'NS'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: NS record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: an.si.ble
ttl: 300
register: cloudflare_dns
- name: "Validate: NS record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'an.si.ble'
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.type == 'NS'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: NS record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: ble.si.an
ttl: 150
solo: true
register: cloudflare_dns
- name: "Validate: NS record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'ble.si.an'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'NS'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: NS record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: an.si.ble
ttl: 300
state: absent
register: cloudflare_dns
- name: "Validate: NS record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: NS record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: ble.si.an
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: NS record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: NS record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: NS
value: ble.si.an
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: NS record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,184 @@
---
######## SPF record tests #################
- set_fact:
# values breaking the api: ,<>:
txt_teststring: 'v=spf1 abc123 !@#$%^&*()_+=-;./{}?\|'
- name: "Test: SPF record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: "{{ txt_teststring }}"
ttl: 150
register: cloudflare_dns
- name: "Validate: SPF record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == "{{ txt_teststring }}"
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'SPF'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SPF record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: "{{ txt_teststring }}"
ttl: 150
register: cloudflare_dns
- name: "Validate: SPF record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: SPF record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: "{{ txt_teststring }}"
ttl: 300
register: cloudflare_dns
- name: "Validate: SPF record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- name: "Test: SPF record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: 'v=spf1 teststring'
ttl: 150
register: cloudflare_dns
- name: "Validate: SPF record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'v=spf1 teststring'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'SPF'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SPF record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: "{{ txt_teststring }}"
ttl: 300
register: cloudflare_dns
- name: "Validate: SPF record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == "{{ txt_teststring }}"
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.type == 'SPF'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SPF record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: 'v=spf1 teststring'
ttl: 150
solo: true
register: cloudflare_dns
- name: "Validate: SPF record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'v=spf1 teststring'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'SPF'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SPF record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: "{{ txt_teststring }}"
ttl: 300
state: absent
register: cloudflare_dns
- name: "Validate: SPF record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: SPF record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: 'v=spf1 teststring'
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: SPF record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: SPF record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SPF
value: 'v=spf1 teststring'
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: SPF record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,266 @@
---
######## SRV record tests #################
- name: "Test: SRV record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}."
ttl: 150
priority: 20
service: srv1
proto: tcp
port: 3500
weight: 5
register: cloudflare_dns
- name: "Validate: SRV record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '5\t3500\tsrv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.data.target == 'srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.data.port == 3500
- cloudflare_dns.result.record.data.weight == 5
- cloudflare_dns.result.record.data.priority == 20
- cloudflare_dns.result.record.data.name == "{{ cloudflare_dns_record }}"
- cloudflare_dns.result.record.data.proto == '_tcp'
- cloudflare_dns.result.record.data.service == '_srv1'
- cloudflare_dns.result.record.type == 'SRV'
- cloudflare_dns.result.record.name == "_srv1._tcp.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SRV record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}."
ttl: 150
priority: 20
service: srv1
proto: tcp
port: 3500
weight: 5
register: cloudflare_dns
- name: "Validate: SRV record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
# changing the following attributes creates a new record:
# weight
# port
# value
# service
# proto
- name: "Test: SRV record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 300
priority: 10
service: srv1
proto: tcp
port: 3500
weight: 5
register: cloudflare_dns
- name: "Validate: SRV record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.data.target == 'srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.data.port == 3500
- cloudflare_dns.result.record.data.weight == 5
- cloudflare_dns.result.record.data.priority == 10
- cloudflare_dns.result.record.data.name == "{{ cloudflare_dns_record }}"
- cloudflare_dns.result.record.data.proto == '_tcp'
- cloudflare_dns.result.record.data.service == '_srv1'
- name: "Test: SRV record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
service: srv1
proto: tcp
port: 9999
weight: 19
register: cloudflare_dns
- name: "Validate: SRV record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '19\t9999\tsrv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.data.target == 'srv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.data.port == 9999
- cloudflare_dns.result.record.data.weight == 19
- cloudflare_dns.result.record.data.priority == 30
- cloudflare_dns.result.record.data.name == "{{ cloudflare_dns_record }}"
- cloudflare_dns.result.record.data.proto == '_tcp'
- cloudflare_dns.result.record.data.service == '_srv1'
- cloudflare_dns.result.record.type == 'SRV'
- cloudflare_dns.result.record.name == "_srv1._tcp.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SRV record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 300
priority: 10
service: srv1
proto: tcp
port: 3500
weight: 5
register: cloudflare_dns
- name: "Validate: SRV record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == '5\t3500\tsrv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.data.target == 'srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.data.port == 3500
- cloudflare_dns.result.record.data.weight == 5
- cloudflare_dns.result.record.data.priority == 10
- cloudflare_dns.result.record.data.name == "{{ cloudflare_dns_record }}"
- cloudflare_dns.result.record.data.proto == '_tcp'
- cloudflare_dns.result.record.data.service == '_srv1'
- cloudflare_dns.result.record.type == 'SRV'
- cloudflare_dns.result.record.name == "_srv1._tcp.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SRV record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
service: srv1
proto: tcp
port: 9999
weight: 19
solo: true
register: cloudflare_dns
- name: "Validate: SRV record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == '19\t9999\tsrv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.data.target == 'srv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}'
- cloudflare_dns.result.record.data.port == 9999
- cloudflare_dns.result.record.data.weight == 19
- cloudflare_dns.result.record.data.priority == 30
- cloudflare_dns.result.record.data.name == "{{ cloudflare_dns_record }}"
- cloudflare_dns.result.record.data.proto == '_tcp'
- cloudflare_dns.result.record.data.service == '_srv1'
- cloudflare_dns.result.record.type == 'SRV'
- cloudflare_dns.result.record.name == "_srv1._tcp.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: SRV record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv1.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 300
priority: 10
service: srv1
proto: tcp
port: 3500
weight: 5
state: absent
register: cloudflare_dns
- name: "Validate: SRV record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: SRV record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
service: srv1
proto: tcp
port: 9999
weight: 19
state: absent
register: cloudflare_dns
- name: "Validate: SRV record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: SRV record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: SRV
value: "srv2.{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
ttl: 150
priority: 30
service: srv1
proto: tcp
port: 9999
weight: 19
state: absent
register: cloudflare_dns
- name: "Validate: SRV record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed

View file

@ -0,0 +1,184 @@
---
######## TXT record tests #################
- set_fact:
# values breaking the api: ,<>:
txt_teststring: 'abc123 !@#$%^&*()_+=-;./{}?\|'
- name: "Test: TXT record creation"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: "{{ txt_teststring }}"
ttl: 150
register: cloudflare_dns
- name: "Validate: TXT record creation"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == "{{ txt_teststring }}"
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'TXT'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: TXT record idempotency"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: "{{ txt_teststring }}"
ttl: 150
register: cloudflare_dns
- name: "Validate: TXT record idempotency"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: TXT record update"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: "{{ txt_teststring }}"
ttl: 300
register: cloudflare_dns
- name: "Validate: TXT record update"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.ttl == 300
- name: "Test: TXT record duplicate (create new record)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: 'teststring'
ttl: 150
register: cloudflare_dns
- name: "Validate: TXT record duplicate (create new record)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'teststring'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'TXT'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: TXT record duplicate (old record present)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: "{{ txt_teststring }}"
ttl: 300
register: cloudflare_dns
- name: "Validate: TXT record duplicate (old record present)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- cloudflare_dns.result.record.content == "{{ txt_teststring }}"
- cloudflare_dns.result.record.ttl == 300
- cloudflare_dns.result.record.type == 'TXT'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: TXT record duplicate (make new record solo)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: 'teststring'
ttl: 150
solo: true
register: cloudflare_dns
- name: "Validate: TXT record duplicate (make new record solo)"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- cloudflare_dns.result.record.content == 'teststring'
- cloudflare_dns.result.record.ttl == 150
- cloudflare_dns.result.record.type == 'TXT'
- cloudflare_dns.result.record.name == "{{ cloudflare_dns_record }}.{{ cloudflare_zone }}"
- cloudflare_dns.result.record.zone_name == "{{ cloudflare_zone }}"
- name: "Test: TXT record duplicate (old record absent)"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: "{{ txt_teststring }}"
ttl: 300
state: absent
register: cloudflare_dns
- name: "Validate: TXT record duplicate (old record absent)"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed
- name: "Test: TXT record deletion"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: 'teststring'
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: TXT record deletion"
assert:
that:
- cloudflare_dns|success
- cloudflare_dns|changed
- name: "Test: TXT record deletion succeeded"
cloudflare_dns:
account_email: "{{ cloudflare_email }}"
account_api_token: "{{ cloudflare_api_token }}"
zone: "{{ cloudflare_zone }}"
record: "{{ cloudflare_dns_record }}"
type: TXT
value: 'teststring'
ttl: 150
state: absent
register: cloudflare_dns
- name: "Validate: TXT record deletion succeeded"
assert:
that:
- cloudflare_dns|success
- not cloudflare_dns|changed