Note
This lookup plugin is part of the community.dns collection (version 3.3.0).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.dns. You need further requirements to be able to use this lookup plugin, see Requirements for details.
To use it in a playbook, specify: community.dns.lookup.
New in community.dns 2.6.0
The below requirements are needed on the local controller node that executes this lookup.
server)Parameter | Comments |
|---|---|
Terms list / elements=string / required | Domain name(s) to query. |
This describes keyword parameters of the lookup. These are the values key1=value1, key2=value2 and so on in the following examples: lookup('community.dns.lookup', key1=value1, key2=value2, ...) and query('community.dns.lookup', key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
nxdomain_handling string | How to handle NXDOMAIN errors. These appear if an unknown domain name is queried.
Choices:
|
query_retry integer | Number of retries for DNS query timeouts. Default: |
query_timeout float | Timeout per DNS query in seconds. Default: |
search boolean added in community.dns 3.0.0 | If If Note that this behavior changed in community.dns 3.0.0. In community.dns 2.x.y, Choices:
|
server list / elements=string | The DNS server(s) to use to look up the result. Must be a list of one or more IP addresses. By default, the system’s standard resolver is used. |
servfail_retries integer | How often to retry on SERVFAIL errors. Default: |
type string | The record type to retrieve. Choices:
|
Note
lookup('community.dns.lookup', term1, term2, key1=value1, key2=value2) and query('community.dns.lookup', term1, term2, key1=value1, key2=value2)
lookup(), and the result is a one-element list, Ansible simply returns the one element not as a list. Since this behavior is surprising and can cause problems, it is better to use query() instead of lookup(). See the examples and also Forcing lookups to return lists in the Ansible documentation.- name: Look up A (IPv4) records for example.org
ansible.builtin.debug:
msg: "{{ query('community.dns.lookup', 'example.org.') }}"
- name: Look up AAAA (IPv6) records for example.org
ansible.builtin.debug:
msg: "{{ query('community.dns.lookup', 'example.org.', type='AAAA' ) }}"
Key | Description |
|---|---|
Return value list / elements=string |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/dns/lookup_lookup.html