| 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: "[username/password] Ensure that lxml is installed" |
| 7 |
ansible.builtin.pip: |
| 8 |
name: lxml |
| 9 |
|
| 10 |
- name: "[username/password] Get zone info" |
| 11 |
community.dns.hosttech_dns_zone_info: |
| 12 |
zone_name: '{{ test_zone }}' |
| 13 |
hosttech_username: '{{ hosttech_username }}' |
| 14 |
hosttech_password: '{{ hosttech_password }}' |
| 15 |
register: result_zone |
| 16 |
|
| 17 |
- name: "[username/password] Get zone info by ID" |
| 18 |
community.dns.hosttech_dns_zone_info: |
| 19 |
zone_id: '{{ result_zone.zone_id }}' |
| 20 |
hosttech_username: '{{ hosttech_username }}' |
| 21 |
hosttech_password: '{{ hosttech_password }}' |
| 22 |
register: result_zone_id |
| 23 |
|
| 24 |
- name: "[username/password] Get all NS records" |
| 25 |
community.dns.hosttech_dns_record_set_info: |
| 26 |
zone_name: '{{ test_zone }}' |
| 27 |
record: '{{ test_zone }}' |
| 28 |
type: NS |
| 29 |
hosttech_username: '{{ hosttech_username }}' |
| 30 |
hosttech_password: '{{ hosttech_password }}' |
| 31 |
register: result |
| 32 |
|
| 33 |
- name: "[username/password] Output all records" |
| 34 |
ansible.builtin.debug: |
| 35 |
var: result |
| 36 |
|
| 37 |
- name: "[username/password] Check results" |
| 38 |
ansible.builtin.assert: |
| 39 |
that: |
| 40 |
- result_zone == result_zone_id |
| 41 |
- result_zone.zone_name == test_zone |
| 42 |
- result_zone.zone_id == result.zone_id |
| 43 |
- result.set |
| 44 |
|
| 45 |
- name: "[username/password] Set zone ID" |
| 46 |
ansible.builtin.set_fact: |
| 47 |
hosttech_zone_id: "{{ result.zone_id }}" |
| 48 |
|
| 49 |
- name: "[username/password] Ensure that test record is not present" |
| 50 |
community.dns.hosttech_dns_record_set: |
| 51 |
state: present |
| 52 |
zone_name: '{{ test_zone }}' |
| 53 |
record: '{{ test_record }}' |
| 54 |
type: A |
| 55 |
ttl: 300 |
| 56 |
value: [] |
| 57 |
hosttech_username: '{{ hosttech_username }}' |
| 58 |
hosttech_password: '{{ hosttech_password }}' |
| 59 |
|
| 60 |
- name: "[username/password] Run tests with cleanup" |
| 61 |
block: |
| 62 |
|
| 63 |
- name: "[username/password] Get test record" |
| 64 |
community.dns.hosttech_dns_record_set_info: |
| 65 |
zone_id: '{{ hosttech_zone_id }}' |
| 66 |
record: '{{ test_record }}' |
| 67 |
type: A |
| 68 |
hosttech_username: '{{ hosttech_username }}' |
| 69 |
hosttech_password: '{{ hosttech_password }}' |
| 70 |
register: rec |
| 71 |
|
| 72 |
- name: "[username/password] Check results" |
| 73 |
ansible.builtin.assert: |
| 74 |
that: |
| 75 |
- not rec.set |
| 76 |
|
| 77 |
- name: "[username/password] Create test record" |
| 78 |
community.dns.hosttech_dns_record_set: |
| 79 |
state: present |
| 80 |
zone_name: '{{ test_zone }}' |
| 81 |
record: '{{ test_record }}' |
| 82 |
type: A |
| 83 |
ttl: 300 |
| 84 |
value: |
| 85 |
- 1.2.3.4 |
| 86 |
- 1.2.3.5 |
| 87 |
- 1.2.3.6 |
| 88 |
hosttech_username: '{{ hosttech_username }}' |
| 89 |
hosttech_password: '{{ hosttech_password }}' |
| 90 |
|
| 91 |
- name: "[username/password] Modify test record" |
| 92 |
community.dns.hosttech_dns_record_set: |
| 93 |
state: present |
| 94 |
zone_name: '{{ test_zone }}' |
| 95 |
prefix: '{{ test_record_prefix }}' |
| 96 |
type: A |
| 97 |
ttl: 300 |
| 98 |
value: |
| 99 |
- 1.2.3.4 |
| 100 |
- 1.2.3.7 |
| 101 |
hosttech_username: '{{ hosttech_username }}' |
| 102 |
hosttech_password: '{{ hosttech_password }}' |
| 103 |
|
| 104 |
- name: "[username/password] Add test record" |
| 105 |
community.dns.hosttech_dns_record: |
| 106 |
state: present |
| 107 |
zone_name: '{{ test_zone }}' |
| 108 |
prefix: '{{ test_record_prefix }}' |
| 109 |
type: A |
| 110 |
ttl: 300 |
| 111 |
value: 1.2.3.8 |
| 112 |
hosttech_username: '{{ hosttech_username }}' |
| 113 |
hosttech_password: '{{ hosttech_password }}' |
| 114 |
|
| 115 |
- name: "[username/password] Remove test record" |
| 116 |
community.dns.hosttech_dns_record: |
| 117 |
state: absent |
| 118 |
zone_name: '{{ test_zone }}' |
| 119 |
prefix: '{{ test_record_prefix }}' |
| 120 |
type: A |
| 121 |
ttl: 300 |
| 122 |
value: 1.2.3.4 |
| 123 |
hosttech_username: '{{ hosttech_username }}' |
| 124 |
hosttech_password: '{{ hosttech_password }}' |
| 125 |
|
| 126 |
- name: "[username/password] Get test record" |
| 127 |
community.dns.hosttech_dns_record_set_info: |
| 128 |
zone_name: '{{ test_zone }}' |
| 129 |
record: '{{ test_record }}' |
| 130 |
type: A |
| 131 |
hosttech_username: '{{ hosttech_username }}' |
| 132 |
hosttech_password: '{{ hosttech_password }}' |
| 133 |
register: rec |
| 134 |
|
| 135 |
- name: "[username/password] Check results" |
| 136 |
ansible.builtin.assert: |
| 137 |
that: |
| 138 |
- rec.set |
| 139 |
- rec.set.record == test_record |
| 140 |
- rec.set.type == 'A' |
| 141 |
- rec.set.ttl == 300 |
| 142 |
- rec.set.value | length == 2 |
| 143 |
- rec.set.value | sort == ['1.2.3.7', '1.2.3.8'] |
| 144 |
|
| 145 |
- name: "[username/password] Delete test record" |
| 146 |
community.dns.hosttech_dns_record_set: |
| 147 |
state: absent |
| 148 |
zone_id: '{{ hosttech_zone_id }}' |
| 149 |
record: '{{ rec.set.record }}' |
| 150 |
ttl: '{{ rec.set.ttl }}' |
| 151 |
type: '{{ rec.set.type }}' |
| 152 |
value: '{{ rec.set.value }}' |
| 153 |
on_existing: keep_and_fail |
| 154 |
hosttech_username: '{{ hosttech_username }}' |
| 155 |
hosttech_password: '{{ hosttech_password }}' |
| 156 |
|
| 157 |
always: |
| 158 |
- name: "[username/password] Ensure that test record is not present" |
| 159 |
community.dns.hosttech_dns_record_set: |
| 160 |
state: absent |
| 161 |
zone_name: '{{ test_zone }}' |
| 162 |
record: '{{ test_record }}' |
| 163 |
type: A |
| 164 |
ttl: 300 |
| 165 |
hosttech_username: '{{ hosttech_username }}' |
| 166 |
hosttech_password: '{{ hosttech_password }}' |