2017-08-30 01:15:09 +00:00
|
|
|
- name: Create random domain name
|
|
|
|
set_fact:
|
|
|
|
domain_name: "{{ resource_group | hash('md5') | truncate(16, True, '') + (65535 | random | string) }}"
|
|
|
|
|
2017-08-29 17:49:37 +00:00
|
|
|
- name: Create a DNS zone
|
|
|
|
azure_rm_dnszone:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-30 01:15:09 +00:00
|
|
|
name: "{{ domain_name }}.com"
|
2017-08-29 17:49:37 +00:00
|
|
|
state: present
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: results.changed
|
|
|
|
|
|
|
|
- name: Update DNS zone with tags
|
|
|
|
azure_rm_dnszone:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-30 01:15:09 +00:00
|
|
|
name: "{{ domain_name }}.com"
|
2017-08-29 17:49:37 +00:00
|
|
|
state: present
|
|
|
|
tags:
|
|
|
|
test: modified
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- results.changed
|
|
|
|
- results.state.tags.test == 'modified'
|
|
|
|
|
|
|
|
- name: Test check_mode
|
|
|
|
azure_rm_dnszone:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-30 01:15:09 +00:00
|
|
|
name: "{{ domain_name }}.com"
|
2017-08-29 17:49:37 +00:00
|
|
|
state: present
|
|
|
|
tags:
|
|
|
|
test: new_modified
|
|
|
|
check_mode: yes
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- results.changed
|
|
|
|
- results.state.tags.test == 'new_modified'
|
|
|
|
- results.check_mode == true
|
|
|
|
|
2018-09-07 04:50:51 +00:00
|
|
|
- name: Retrieve DNS Zone Facts
|
|
|
|
azure_rm_dnszone_facts:
|
|
|
|
resource_group: "{{ resource_group }}"
|
|
|
|
name: "{{ domain_name }}.com"
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- name: Assert that facts module returned result
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not results.changed
|
|
|
|
- results.ansible_facts.azure_dnszones[0].tags.test == 'modified'
|
|
|
|
|
2017-08-29 17:49:37 +00:00
|
|
|
- name: Delete DNS zone
|
|
|
|
azure_rm_dnszone:
|
|
|
|
resource_group: "{{ resource_group }}"
|
2017-08-30 01:15:09 +00:00
|
|
|
name: "{{ domain_name }}.com"
|
2017-08-29 17:49:37 +00:00
|
|
|
state: absent
|