| 1 |
--- |
| 2 |
# Copyright (c) Ansible Project |
| 3 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
- name: "[token] Get zone info" |
| 7 |
community.dns.hosttech_dns_zone_info: |
| 8 |
zone_name: '{{ test_zone }}' |
| 9 |
hosttech_token: '{{ hosttech_token }}' |
| 10 |
register: result_zone |
| 11 |
|
| 12 |
- name: "[token] Get zone info by ID" |
| 13 |
community.dns.hosttech_dns_zone_info: |
| 14 |
zone_id: '{{ result_zone.zone_id }}' |
| 15 |
hosttech_token: '{{ hosttech_token }}' |
| 16 |
register: result_zone_id |
| 17 |
|
| 18 |
- name: "[token] Get all NS records" |
| 19 |
community.dns.hosttech_dns_record_set_info: |
| 20 |
zone_name: '{{ test_zone }}' |
| 21 |
record: '{{ test_zone }}' |
| 22 |
type: NS |
| 23 |
hosttech_token: '{{ hosttech_token }}' |
| 24 |
register: result |
| 25 |
|
| 26 |
- name: "[token] Output all records" |
| 27 |
ansible.builtin.debug: |
| 28 |
var: result |
| 29 |
|
| 30 |
- name: "[token] Check results" |
| 31 |
ansible.builtin.assert: |
| 32 |
that: |
| 33 |
- result_zone == result_zone_id |
| 34 |
- result_zone.zone_name == test_zone |
| 35 |
- result_zone.zone_id == result.zone_id |
| 36 |
- result.set |
| 37 |
|
| 38 |
- name: "[token] Set zone ID" |
| 39 |
ansible.builtin.set_fact: |
| 40 |
hosttech_zone_id: "{{ result.zone_id }}" |
| 41 |
|
| 42 |
- name: "[token] Ensure that test record is not present" |
| 43 |
community.dns.hosttech_dns_record_set: |
| 44 |
state: present |
| 45 |
zone_name: '{{ test_zone }}' |
| 46 |
record: '{{ test_record }}' |
| 47 |
type: A |
| 48 |
ttl: 600 |
| 49 |
value: [] |
| 50 |
hosttech_token: '{{ hosttech_token }}' |
| 51 |
|
| 52 |
- name: "[token] Run tests with cleanup" |
| 53 |
block: |
| 54 |
|
| 55 |
- name: "[token] Get test record" |
| 56 |
community.dns.hosttech_dns_record_set_info: |
| 57 |
zone_id: '{{ hosttech_zone_id }}' |
| 58 |
record: '{{ test_record }}' |
| 59 |
type: A |
| 60 |
hosttech_token: '{{ hosttech_token }}' |
| 61 |
register: rec |
| 62 |
|
| 63 |
- name: "[token] Check results" |
| 64 |
ansible.builtin.assert: |
| 65 |
that: |
| 66 |
- not rec.set |
| 67 |
|
| 68 |
- name: "[token] Create test record" |
| 69 |
community.dns.hosttech_dns_record_set: |
| 70 |
state: present |
| 71 |
zone_name: '{{ test_zone }}' |
| 72 |
record: '{{ test_record }}' |
| 73 |
type: A |
| 74 |
ttl: 600 |
| 75 |
value: |
| 76 |
- 1.2.3.4 |
| 77 |
- 1.2.3.5 |
| 78 |
- 1.2.3.6 |
| 79 |
hosttech_token: '{{ hosttech_token }}' |
| 80 |
|
| 81 |
- name: "[token] Modify test record" |
| 82 |
community.dns.hosttech_dns_record_set: |
| 83 |
state: present |
| 84 |
zone_name: '{{ test_zone }}' |
| 85 |
prefix: '{{ test_record_prefix }}' |
| 86 |
type: A |
| 87 |
ttl: 600 |
| 88 |
value: |
| 89 |
- 1.2.3.4 |
| 90 |
- 1.2.3.7 |
| 91 |
hosttech_token: '{{ hosttech_token }}' |
| 92 |
|
| 93 |
- name: "[token] Add test record" |
| 94 |
community.dns.hosttech_dns_record: |
| 95 |
state: present |
| 96 |
zone_name: '{{ test_zone }}' |
| 97 |
prefix: '{{ test_record_prefix }}' |
| 98 |
type: A |
| 99 |
ttl: 600 |
| 100 |
value: 1.2.3.8 |
| 101 |
hosttech_token: '{{ hosttech_token }}' |
| 102 |
|
| 103 |
- name: "[token] Remove test record" |
| 104 |
community.dns.hosttech_dns_record: |
| 105 |
state: absent |
| 106 |
zone_name: '{{ test_zone }}' |
| 107 |
prefix: '{{ test_record_prefix }}' |
| 108 |
type: A |
| 109 |
ttl: 600 |
| 110 |
value: 1.2.3.4 |
| 111 |
hosttech_token: '{{ hosttech_token }}' |
| 112 |
|
| 113 |
- name: "[token] Get test record" |
| 114 |
community.dns.hosttech_dns_record_set_info: |
| 115 |
zone_name: '{{ test_zone }}' |
| 116 |
record: '{{ test_record }}' |
| 117 |
type: A |
| 118 |
hosttech_token: '{{ hosttech_token }}' |
| 119 |
register: rec |
| 120 |
|
| 121 |
- name: "[token] Check results" |
| 122 |
ansible.builtin.assert: |
| 123 |
that: |
| 124 |
- rec.set |
| 125 |
- rec.set.record == test_record |
| 126 |
- rec.set.type == 'A' |
| 127 |
- rec.set.ttl == 600 |
| 128 |
- rec.set.value | length == 2 |
| 129 |
- rec.set.value | sort == ['1.2.3.7', '1.2.3.8'] |
| 130 |
|
| 131 |
- name: "[token] Delete test record" |
| 132 |
community.dns.hosttech_dns_record_set: |
| 133 |
state: absent |
| 134 |
zone_id: '{{ hosttech_zone_id }}' |
| 135 |
record: '{{ rec.set.record }}' |
| 136 |
ttl: '{{ rec.set.ttl }}' |
| 137 |
type: '{{ rec.set.type }}' |
| 138 |
value: '{{ rec.set.value }}' |
| 139 |
on_existing: keep_and_fail |
| 140 |
hosttech_token: '{{ hosttech_token }}' |
| 141 |
|
| 142 |
always: |
| 143 |
- name: "[token] Ensure that test record is not present" |
| 144 |
community.dns.hosttech_dns_record_set: |
| 145 |
state: absent |
| 146 |
zone_name: '{{ test_zone }}' |
| 147 |
record: '{{ test_record }}' |
| 148 |
type: A |
| 149 |
ttl: 600 |
| 150 |
hosttech_token: '{{ hosttech_token }}' |