| 1 |
--- |
| 2 |
#################################################################### |
| 3 |
# WARNING: These are designed specifically for Ansible tests # |
| 4 |
# and should not be used as examples of how to write Ansible roles # |
| 5 |
#################################################################### |
| 6 |
|
| 7 |
# Test code for ipwcli_dns |
| 8 |
# Copyright (c) Ansible Project |
| 9 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 10 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 11 |
|
| 12 |
- name: variables username, password, container, tld must be set |
| 13 |
fail: |
| 14 |
msg: 'Please set the variables: username, password, container and tld.' |
| 15 |
when: username is not defined or password is not defined or container is not defined or tld is not defined |
| 16 |
|
| 17 |
- name: add a new A record |
| 18 |
ipwcli_dns: |
| 19 |
dnsname: example.{{ tld }} |
| 20 |
type: A |
| 21 |
container: '{{ container }}' |
| 22 |
address: 127.0.0.1 |
| 23 |
ttl: 100 |
| 24 |
username: '{{ username }}' |
| 25 |
password: '{{ password }}' |
| 26 |
register: result |
| 27 |
|
| 28 |
- name: assert the new A record is added |
| 29 |
assert: |
| 30 |
that: |
| 31 |
- result is not failed |
| 32 |
- result is changed |
| 33 |
- result.record == 'arecord example.{{ tld }} 127.0.0.1 -set ttl=100;container={{ container }}' |
| 34 |
|
| 35 |
- name: delete the A record |
| 36 |
ipwcli_dns: |
| 37 |
dnsname: example.{{ tld }} |
| 38 |
type: A |
| 39 |
container: '{{ container }}' |
| 40 |
address: 127.0.0.1 |
| 41 |
ttl: 100 |
| 42 |
username: '{{ username }}' |
| 43 |
password: '{{ password }}' |
| 44 |
state: absent |
| 45 |
register: result |
| 46 |
|
| 47 |
- name: assert the new A record is deleted |
| 48 |
assert: |
| 49 |
that: |
| 50 |
- result is not failed |
| 51 |
- result is changed |
| 52 |
- result.record == 'arecord example.{{ tld }} 127.0.0.1 -set ttl=100;container={{ container }}' |
| 53 |
|
| 54 |
- name: delete not existing SRV record |
| 55 |
ipwcli_dns: |
| 56 |
dnsname: _sip._tcp.test.example.{{ tld }} |
| 57 |
type: SRV |
| 58 |
container: '{{ container }}' |
| 59 |
target: example.{{ tld }} |
| 60 |
port: 5060 |
| 61 |
username: '{{ username }}' |
| 62 |
password: '{{ password }}' |
| 63 |
state: absent |
| 64 |
register: result |
| 65 |
|
| 66 |
- name: assert the new a record |
| 67 |
assert: |
| 68 |
that: |
| 69 |
- result is not failed |
| 70 |
- result is not changed |
| 71 |
- result.record == |
| 72 |
'srvrecord _sip._tcp.test.example.{{ tld }} -set ttl=3600;container={{ container }};priority=10;weight=10;port=5060;target=example.{{ tld }}' |
| 73 |
|
| 74 |
- name: add a SRV record with weight > 65535 against RFC 2782 |
| 75 |
ipwcli_dns: |
| 76 |
dnsname: _sip._tcp.test.example.{{ tld }} |
| 77 |
type: SRV |
| 78 |
container: '{{ container }}' |
| 79 |
ttl: 100 |
| 80 |
target: example.{{ tld }} |
| 81 |
port: 5060 |
| 82 |
weight: 65536 |
| 83 |
username: '{{ username }}' |
| 84 |
password: '{{ password }}' |
| 85 |
register: result |
| 86 |
ignore_errors: true |
| 87 |
|
| 88 |
- name: assert the failure of the new SRV record |
| 89 |
assert: |
| 90 |
that: |
| 91 |
- result is failed |
| 92 |
- result is not changed |
| 93 |
- "'Out of UINT16 range' in result.stderr" |
| 94 |
|
| 95 |
- name: add NAPTR record (check_mode) |
| 96 |
ipwcli_dns: |
| 97 |
dnsname: test.example.{{ tld }} |
| 98 |
type: NAPTR |
| 99 |
preference: 10 |
| 100 |
container: '{{ container }}' |
| 101 |
ttl: 100 |
| 102 |
order: 10 |
| 103 |
service: 'SIP+D2T' |
| 104 |
replacement: '_sip._tcp.test.example.{{ tld }}.' |
| 105 |
flags: S |
| 106 |
username: '{{ username }}' |
| 107 |
password: '{{ password }}' |
| 108 |
check_mode: true |
| 109 |
register: result |
| 110 |
|
| 111 |
- name: assert the NAPTR check_mode |
| 112 |
assert: |
| 113 |
that: |
| 114 |
- result is not failed |
| 115 |
- result is changed |