1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

consolidating dns recordset tests (#45331)

This commit is contained in:
Zim Kalinowski 2018-09-07 14:49:38 +08:00 committed by Yunge Zhu
parent 38a714833d
commit fca1dc4cf2
8 changed files with 209 additions and 257 deletions

View file

@ -1,3 +0,0 @@
cloud/azure
shippable/azure/group1
destructive

View file

@ -1,2 +0,0 @@
dependencies:
- setup_azure

View file

@ -1,185 +0,0 @@
- name: Create random domain name
set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a DNS zone
azure_rm_dnszone:
resource_group: "{{ resource_group }}"
name: "{{ domain_name }}.com"
state: present
register: results
- name: Assert that DNS zone was created
assert:
that: results.changed
- name: create "A" record set with multiple records
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Assert that A record set was created
assert:
that: results.changed
- name: re-run "A" record with same values
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Assert that A record set was not changed
assert:
that: not results.changed
- name: Update "A" record set with additional record
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
record_mode: append
records:
- entry: 192.168.100.104
register: results
- name: Assert that new record was appended
assert:
that:
- results.changed
- name: re-update "A" record set with additional record
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
record_mode: append
records:
- entry: 192.168.100.104
register: results
- name: Assert that A record set was not changed
assert:
that:
- not results.changed
- name: Remove 1 record from record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Assert that record was deleted
assert:
that:
- results.changed
- name: Check_mode test
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.105
check_mode: yes
register: results
- name: Assert that check_mode returns new state
assert:
that:
- results.changed
# FUTURE: add facts module calls to ensure that we really didn't touch anything
- name: delete a record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
state: absent
register: results
- name: Assert that record set deleted
assert:
that: results.changed
- name: (idempotence test) re-run record set absent
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
state: absent
register: results
- name:
assert:
that: not results.changed
- name: create SRV records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_sip._tcp.{{ domain_name }}.com"
zone_name: "{{ domain_name }}.com"
time_to_live: 7200
record_type: SRV
state: present
records:
- entry: sip.{{ domain_name }}.com
priority: 20
weight: 10
port: 5060
register: results
- name: Assert that SRV record set was created
assert:
that:
- results.changed
- name: create TXT records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_txt.{{ domain_name }}.com"
zone_name: "{{ domain_name }}.com"
record_type: TXT
state: present
records:
- entry: "v=spf1 a -all"
- entry: "foo"
- entry:
- "bar"
- "baz"
register: results
- name: Assert that TXT record set was created
assert:
that:
- results.changed
- name: Delete DNS zone
azure_rm_dnszone:
resource_group: "{{ resource_group }}"
name: "{{ domain_name }}.com"
state: absent

View file

@ -1,3 +0,0 @@
cloud/azure
shippable/azure/group1
destructive

View file

@ -1,2 +0,0 @@
dependencies:
- setup_azure

View file

@ -1,62 +0,0 @@
- name: Create random domain name
set_fact:
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
- name: Create a DNS zone
azure_rm_dnszone:
resource_group: "{{ resource_group }}"
name: "{{ domain_name }}.com"
state: present
tags:
tag1: tag1
register: results
- name: Assert DNS Zone was created
assert:
that: results.changed
- name: create new "A" record set with multiple records
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Retrieve DNS Record Set Facts for single Record Set
azure_rm_dnsrecordset_facts:
resource_group: "{{ resource_group }}"
zone_name: "{{ domain_name }}.com"
relative_name: www
record_type: A
register: results
- name: Assert that facts module returned result for single Record Set
assert:
that:
- not results.changed
- results.ansible_facts.azure_dnsrecordset[0].name == 'www'
- name: Retrieve DNS Record Set Facts for all Record Sets
azure_rm_dnsrecordset_facts:
resource_group: "{{ resource_group }}"
zone_name: "{{ domain_name }}.com"
register: results
- name: Assert that facts module returned result for all Record Sets
assert:
that:
- not results.changed
- results.ansible_facts.azure_dnsrecordset[0].name == '@'
- results.ansible_facts.azure_dnsrecordset[1].name == '@'
- results.ansible_facts.azure_dnsrecordset[2].name == 'www'
- name: Delete DNS zone
azure_rm_dnszone:
resource_group: "{{ resource_group }}"
name: "{{ domain_name }}.com"
state: absent

View file

@ -2,3 +2,5 @@ cloud/azure
shippable/azure/group1 shippable/azure/group1
destructive destructive
azure_rm_dnszone_facts azure_rm_dnszone_facts
azure_rm_dnsrecordset
azure_rm_dnsrecordset_facts

View file

@ -54,6 +54,213 @@
- not results.changed - not results.changed
- results.ansible_facts.azure_dnszones[0].tags.test == 'modified' - results.ansible_facts.azure_dnszones[0].tags.test == 'modified'
#
# azure_rm_dnsrecordset test
#
- name: create "A" record set with multiple records
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Assert that A record set was created
assert:
that: results.changed
- name: re-run "A" record with same values
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Assert that A record set was not changed
assert:
that: not results.changed
- name: Update "A" record set with additional record
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
record_mode: append
records:
- entry: 192.168.100.104
register: results
- name: Assert that new record was appended
assert:
that:
- results.changed
- name: re-update "A" record set with additional record
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
record_mode: append
records:
- entry: 192.168.100.104
register: results
- name: Assert that A record set was not changed
assert:
that:
- not results.changed
- name: Remove 1 record from record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.101
- entry: 192.168.100.102
- entry: 192.168.100.103
register: results
- name: Assert that record was deleted
assert:
that:
- results.changed
- name: Check_mode test
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
records:
- entry: 192.168.100.105
check_mode: yes
register: results
- name: Assert that check_mode returns new state
assert:
that:
- results.changed
# FUTURE: add facts module calls to ensure that we really didn't touch anything
- name: create SRV records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_sip._tcp.{{ domain_name }}.com"
zone_name: "{{ domain_name }}.com"
time_to_live: 7200
record_type: SRV
state: present
records:
- entry: sip.{{ domain_name }}.com
priority: 20
weight: 10
port: 5060
register: results
- name: Assert that SRV record set was created
assert:
that:
- results.changed
- name: create TXT records in a new record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: "_txt.{{ domain_name }}.com"
zone_name: "{{ domain_name }}.com"
record_type: TXT
state: present
records:
- entry: "v=spf1 a -all"
- entry: "foo"
- entry:
- "bar"
- "baz"
register: results
- name: Assert that TXT record set was created
assert:
that:
- results.changed
#
# azure_rm_dnsrecordset_facts
#
- name: Retrieve DNS Record Set Facts for single Record Set
azure_rm_dnsrecordset_facts:
resource_group: "{{ resource_group }}"
zone_name: "{{ domain_name }}.com"
relative_name: www
record_type: A
register: results
- name: Assert that facts module returned result for single Record Set
assert:
that:
- not results.changed
- results.ansible_facts.azure_dnsrecordset[0].name == 'www'
- name: Retrieve DNS Record Set Facts for all Record Sets
azure_rm_dnsrecordset_facts:
resource_group: "{{ resource_group }}"
zone_name: "{{ domain_name }}.com"
register: results
- name: Assert that facts module returned result for all Record Sets
assert:
that:
- not results.changed
- results.ansible_facts.azure_dnsrecordset[0].name == '@'
- results.ansible_facts.azure_dnsrecordset[1].name == '@'
- results.ansible_facts.azure_dnsrecordset[4].name == 'www'
#
# azure_rm_dnsrecordset cleanup
#
- name: delete a record set
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
state: absent
register: results
- name: Assert that record set deleted
assert:
that: results.changed
- name: (idempotence test) re-run record set absent
azure_rm_dnsrecordset:
resource_group: "{{ resource_group }}"
relative_name: www
zone_name: "{{ domain_name }}.com"
record_type: A
state: absent
register: results
- name:
assert:
that: not results.changed
#
# azure_rm_dnszone cleanup
#
- name: Delete DNS zone - name: Delete DNS zone
azure_rm_dnszone: azure_rm_dnszone:
resource_group: "{{ resource_group }}" resource_group: "{{ resource_group }}"