| 1 |
- name: Tests when the hosts have a DHCP DNS config |
| 2 |
block: |
| 3 |
# Testcase 0001: Ensure DNS config directly on the host is idempotent for DHCP |
| 4 |
- name: Ensure DHCP config is idempotent when done directly on the host |
| 5 |
vmware_host_dns: |
| 6 |
hostname: '{{ esxi1 }}' |
| 7 |
username: '{{ esxi_user }}' |
| 8 |
password: '{{ esxi_password }}' |
| 9 |
validate_certs: false |
| 10 |
type: 'dhcp' |
| 11 |
device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}" |
| 12 |
register: vmware_host_dns_result_0001 |
| 13 |
|
| 14 |
- name: Ensure DNS config wasn't changed |
| 15 |
assert: |
| 16 |
that: |
| 17 |
- vmware_host_dns_result_0001 is not changed |
| 18 |
|
| 19 |
# Testcase 0002: Change DNS config directly on the host from DHCP to static |
| 20 |
- name: Change DNS config from DHCP to static directly on the host |
| 21 |
vmware_host_dns: |
| 22 |
hostname: '{{ esxi1 }}' |
| 23 |
username: '{{ esxi_user }}' |
| 24 |
password: '{{ esxi_password }}' |
| 25 |
validate_certs: false |
| 26 |
type: 'static' |
| 27 |
host_name: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['host_name'] }}" |
| 28 |
domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}" |
| 29 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 30 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 31 |
register: vmware_host_dns_result_0002 |
| 32 |
|
| 33 |
- name: Ensure DNS config was changed |
| 34 |
assert: |
| 35 |
that: |
| 36 |
- vmware_host_dns_result_0002 is changed |
| 37 |
|
| 38 |
# Testcase 0003: Ensure DNS config directly on the host is idempotent for static |
| 39 |
- name: Ensure static DNS config is idempotent when done directly on the host |
| 40 |
vmware_host_dns: |
| 41 |
hostname: '{{ esxi1 }}' |
| 42 |
username: '{{ esxi_user }}' |
| 43 |
password: '{{ esxi_password }}' |
| 44 |
validate_certs: false |
| 45 |
type: 'static' |
| 46 |
host_name: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['host_name'] }}" |
| 47 |
domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}" |
| 48 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 49 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 50 |
register: vmware_host_dns_result_0003 |
| 51 |
|
| 52 |
- name: Ensure DNS config wasn't changed |
| 53 |
assert: |
| 54 |
that: |
| 55 |
- vmware_host_dns_result_0003 is not changed |
| 56 |
|
| 57 |
# Testcase 0004: Ensure changing the hostname directly on the host works |
| 58 |
- name: Ensure changing the hostname directly on the host works |
| 59 |
vmware_host_dns: |
| 60 |
hostname: '{{ esxi1 }}' |
| 61 |
username: '{{ esxi_user }}' |
| 62 |
password: '{{ esxi_password }}' |
| 63 |
validate_certs: false |
| 64 |
type: 'static' |
| 65 |
host_name: newname |
| 66 |
domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}" |
| 67 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 68 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 69 |
register: vmware_host_dns_result_0004 |
| 70 |
|
| 71 |
- name: Ensure DNS config was changed |
| 72 |
assert: |
| 73 |
that: |
| 74 |
- vmware_host_dns_result_0004 is changed |
| 75 |
|
| 76 |
# Testcase 0005: Ensure changing the domain directly on the host works |
| 77 |
- name: Ensure changing the domain directly on the host works |
| 78 |
vmware_host_dns: |
| 79 |
hostname: '{{ esxi1 }}' |
| 80 |
username: '{{ esxi_user }}' |
| 81 |
password: '{{ esxi_password }}' |
| 82 |
validate_certs: false |
| 83 |
type: 'static' |
| 84 |
host_name: newname |
| 85 |
domain: new.domain |
| 86 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 87 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 88 |
register: vmware_host_dns_result_0005 |
| 89 |
|
| 90 |
- name: Ensure DNS config was changed |
| 91 |
assert: |
| 92 |
that: |
| 93 |
- vmware_host_dns_result_0005 is changed |
| 94 |
|
| 95 |
# Testcase 0006: Ensure changing the DNS servers directly on the host works |
| 96 |
- name: Ensure changing the domain directly on the host works |
| 97 |
vmware_host_dns: |
| 98 |
hostname: '{{ esxi1 }}' |
| 99 |
username: '{{ esxi_user }}' |
| 100 |
password: '{{ esxi_password }}' |
| 101 |
validate_certs: false |
| 102 |
type: 'static' |
| 103 |
host_name: newname |
| 104 |
domain: new.domain |
| 105 |
dns_servers: |
| 106 |
- 1.2.3.4 |
| 107 |
- 5.6.7.8 |
| 108 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 109 |
register: vmware_host_dns_result_0006 |
| 110 |
|
| 111 |
- name: Ensure DNS config was changed |
| 112 |
assert: |
| 113 |
that: |
| 114 |
- vmware_host_dns_result_0006 is changed |
| 115 |
|
| 116 |
# Testcase 0007: Ensure changing the search domain directly on the host works |
| 117 |
- name: Ensure changing the domain directly on the host works |
| 118 |
vmware_host_dns: |
| 119 |
hostname: '{{ esxi1 }}' |
| 120 |
username: '{{ esxi_user }}' |
| 121 |
password: '{{ esxi_password }}' |
| 122 |
validate_certs: false |
| 123 |
type: 'static' |
| 124 |
host_name: newname |
| 125 |
domain: new.domain |
| 126 |
dns_servers: |
| 127 |
- 1.2.3.4 |
| 128 |
- 5.6.7.8 |
| 129 |
search_domains: |
| 130 |
- subdomain.example.local |
| 131 |
- example.local |
| 132 |
register: vmware_host_dns_result_0007 |
| 133 |
|
| 134 |
- name: Ensure DNS config was changed |
| 135 |
assert: |
| 136 |
that: |
| 137 |
- vmware_host_dns_result_0007 is changed |
| 138 |
|
| 139 |
# Testcase 0008: Change DNS config directly on the host from static to DHCP |
| 140 |
- name: Change DNS config from static to DHCP directly on the host |
| 141 |
vmware_host_dns: |
| 142 |
hostname: '{{ esxi1 }}' |
| 143 |
username: '{{ esxi_user }}' |
| 144 |
password: '{{ esxi_password }}' |
| 145 |
validate_certs: false |
| 146 |
type: 'dhcp' |
| 147 |
device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}" |
| 148 |
register: vmware_host_dns_result_0008 |
| 149 |
|
| 150 |
- name: Ensure DNS config was changed |
| 151 |
assert: |
| 152 |
that: |
| 153 |
- vmware_host_dns_result_0008 is changed |
| 154 |
|
| 155 |
# Testcase 0009: Ensure DNS config on the cluster is idempotent for DHCP |
| 156 |
- name: Ensure DHCP config is idempotent when done on the cluster |
| 157 |
vmware_host_dns: |
| 158 |
hostname: '{{ vcenter_hostname }}' |
| 159 |
username: '{{ vcenter_username }}' |
| 160 |
password: '{{ vcenter_password }}' |
| 161 |
cluster_name: "{{ ccr1 }}" |
| 162 |
validate_certs: false |
| 163 |
type: 'dhcp' |
| 164 |
device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}" |
| 165 |
register: vmware_host_dns_result_0009 |
| 166 |
|
| 167 |
- name: Ensure DNS config wasn't changed |
| 168 |
assert: |
| 169 |
that: |
| 170 |
- vmware_host_dns_result_0009 is not changed |
| 171 |
|
| 172 |
# Testcase 0010: Ensure changing DNS config on the cluster from DHCP to static works |
| 173 |
- name: Ensure changing DNS config on the cluster from DHCP to static works |
| 174 |
vmware_host_dns: |
| 175 |
hostname: '{{ vcenter_hostname }}' |
| 176 |
username: '{{ vcenter_username }}' |
| 177 |
password: '{{ vcenter_password }}' |
| 178 |
cluster_name: "{{ ccr1 }}" |
| 179 |
validate_certs: false |
| 180 |
type: 'static' |
| 181 |
domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}" |
| 182 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 183 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 184 |
register: vmware_host_dns_result_0010 |
| 185 |
|
| 186 |
- name: Ensure DNS config was changed |
| 187 |
assert: |
| 188 |
that: |
| 189 |
- vmware_host_dns_result_0010 is changed |
| 190 |
|
| 191 |
# Testcase 0011: Ensure DNS config on the cluster is idempotent for static |
| 192 |
- name: Ensure static DNS config is idempotent when done on the cluster |
| 193 |
vmware_host_dns: |
| 194 |
hostname: '{{ vcenter_hostname }}' |
| 195 |
username: '{{ vcenter_username }}' |
| 196 |
password: '{{ vcenter_password }}' |
| 197 |
cluster_name: "{{ ccr1 }}" |
| 198 |
validate_certs: false |
| 199 |
type: 'static' |
| 200 |
domain: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['domain_name'] }}" |
| 201 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 202 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 203 |
register: vmware_host_dns_result_0011 |
| 204 |
|
| 205 |
- name: Ensure DNS config wasn't changed |
| 206 |
assert: |
| 207 |
that: |
| 208 |
- vmware_host_dns_result_0011 is not changed |
| 209 |
|
| 210 |
# Testcase 0012: Ensure changing the domain on the cluster works |
| 211 |
- name: Ensure changing the domain on the cluster works |
| 212 |
vmware_host_dns: |
| 213 |
hostname: '{{ vcenter_hostname }}' |
| 214 |
username: '{{ vcenter_username }}' |
| 215 |
password: '{{ vcenter_password }}' |
| 216 |
cluster_name: "{{ ccr1 }}" |
| 217 |
validate_certs: false |
| 218 |
type: 'static' |
| 219 |
domain: new.domain |
| 220 |
dns_servers: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['ip_address'] }}" |
| 221 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 222 |
register: vmware_host_dns_result_0012 |
| 223 |
|
| 224 |
- name: Ensure DNS config was changed |
| 225 |
assert: |
| 226 |
that: |
| 227 |
- vmware_host_dns_result_0012 is changed |
| 228 |
|
| 229 |
# Testcase 0013: Ensure changing the DNS servers on the cluster works |
| 230 |
- name: Ensure changing the DNS servers on the cluster works |
| 231 |
vmware_host_dns: |
| 232 |
hostname: '{{ vcenter_hostname }}' |
| 233 |
username: '{{ vcenter_username }}' |
| 234 |
password: '{{ vcenter_password }}' |
| 235 |
cluster_name: "{{ ccr1 }}" |
| 236 |
validate_certs: false |
| 237 |
type: 'static' |
| 238 |
domain: new.domain |
| 239 |
dns_servers: |
| 240 |
- 1.2.3.4 |
| 241 |
- 5.6.7.8 |
| 242 |
search_domains: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['search_domain'] }}" |
| 243 |
register: vmware_host_dns_result_0013 |
| 244 |
|
| 245 |
- name: Ensure DNS config was changed |
| 246 |
assert: |
| 247 |
that: |
| 248 |
- vmware_host_dns_result_0013 is changed |
| 249 |
|
| 250 |
# Testcase 0014: Ensure changing the search domains on the cluster works |
| 251 |
- name: Ensure changing the search domains on the cluster works |
| 252 |
vmware_host_dns: |
| 253 |
hostname: '{{ vcenter_hostname }}' |
| 254 |
username: '{{ vcenter_username }}' |
| 255 |
password: '{{ vcenter_password }}' |
| 256 |
cluster_name: "{{ ccr1 }}" |
| 257 |
validate_certs: false |
| 258 |
type: 'static' |
| 259 |
domain: new.domain |
| 260 |
dns_servers: |
| 261 |
- 1.2.3.4 |
| 262 |
- 5.6.7.8 |
| 263 |
search_domains: |
| 264 |
- subdomain.example.local |
| 265 |
- example.local |
| 266 |
register: vmware_host_dns_result_0014 |
| 267 |
|
| 268 |
- name: Ensure DNS config was changed |
| 269 |
assert: |
| 270 |
that: |
| 271 |
- vmware_host_dns_result_0014 is changed |
| 272 |
|
| 273 |
# Testcase 0015: Ensure changing DNS config on the cluster from static to DHCP works |
| 274 |
- name: Ensure changing DNS config on the cluster from static to DHCP works |
| 275 |
vmware_host_dns: |
| 276 |
hostname: '{{ vcenter_hostname }}' |
| 277 |
username: '{{ vcenter_username }}' |
| 278 |
password: '{{ vcenter_password }}' |
| 279 |
cluster_name: "{{ ccr1 }}" |
| 280 |
validate_certs: false |
| 281 |
type: 'dhcp' |
| 282 |
device: "{{ dns['results'][0]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}" |
| 283 |
register: vmware_host_dns_result_0015 |
| 284 |
|
| 285 |
- name: Ensure DNS config was changed |
| 286 |
assert: |
| 287 |
that: |
| 288 |
- vmware_host_dns_result_0015 is changed |
| 289 |
|
| 290 |
always: |
| 291 |
# Revert to original DNS configuration |
| 292 |
- name: Revert to original DNS configuration |
| 293 |
vmware_host_dns: |
| 294 |
hostname: '{{ vcenter_hostname }}' |
| 295 |
username: '{{ vcenter_username }}' |
| 296 |
password: '{{ vcenter_password }}' |
| 297 |
esxi_hostname: "{{ item }}" |
| 298 |
validate_certs: false |
| 299 |
type: 'dhcp' |
| 300 |
device: "{{ dns['results'][index]['hosts_dns_info'][esxi1]['virtual_nic_device'] }}" |
| 301 |
loop: "{{ esxi_hosts }}" |
| 302 |
loop_control: |
| 303 |
index_var: index |