Debian Codegraph @

ansible_collections/community/dns/tests/integration/targets/lookup_lookup/tasks/main.yml

raw
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: Look up some records
7 ansible.builtin.set_fact:
8 ansible_a: >-
9 {{ query('community.dns.lookup', 'ansible.com', type='A') }}
10 ansible_aaaa: >-
11 {{ query('community.dns.lookup', 'www.ansible.com', type='AAAA', server='9.9.9.9') }}
12 ansible_txt: >-
13 {{ query('community.dns.lookup', 'ansible.com', type='TXT', server=['1.1.1.1', '8.8.8.8', 'dns9.quad9.net.']) }}
14 ansible_empty: >-
15 {{ query('community.dns.lookup', 'does-not-exist.ansible.com') }}
16
17 - name: Check results
18 ansible.builtin.assert:
19 that:
20 - ansible_a | length > 0
21 - ansible_a[0] is regex("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
22 - ansible_aaaa | length > 0
23 - ansible_aaaa[0] is regex("^[0-9a-fA-F:]+$")
24 - ansible_txt | length > 0
25 - ansible_txt[0] is string
26 - ansible_empty | length == 0
27
28 - name: Test with invalid nameserver IP
29 ansible.builtin.set_fact:
30 broken: >-
31 {{ query('community.dns.lookup', 'www.ansible.com', type='A', server='999.999.999.999') }}
32 register: result
33 ignore_errors: true
34
35 - name: Check results
36 ansible.builtin.assert:
37 that:
38 - result is failed
39 - >-
40 "Nameserver 999.999.999.999 does not exist" in result.msg