community.dns.reverse_lookup lookup – Reverse-look up IP addresses
Note
This lookup plugin is part of the community.dns collection (version 3.1.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.reverse_lookup
.
New in community.dns 3.1.0
Synopsis
Look up hostnames for IP addresses using DNS reverse lookup.
Requirements
The below requirements are needed on the local controller node that executes this lookup.
dnspython >= 1.15.0 (maybe older versions also work)
Terms
Parameter |
Comments |
---|---|
IP address(es) to look up. |
Keyword parameters
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.reverse_lookup', key1=value1, key2=value2, ...)
and query('community.dns.reverse_lookup', key1=value1, key2=value2, ...)
Parameter |
Comments |
---|---|
Number of retries for DNS query timeouts. Default: |
|
Timeout per DNS query in seconds. Default: |
|
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. |
|
How often to retry on SERVFAIL errors. Default: |
Notes
Note
When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters:
lookup('community.dns.reverse_lookup', term1, term2, key1=value1, key2=value2)
andquery('community.dns.reverse_lookup', term1, term2, key1=value1, key2=value2)
Note that when using this lookup plugin with
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 usequery()
instead oflookup()
. See the examples and also Forcing lookups to return lists in the Ansible documentation.
Examples
- name: Look up hostname of IPv4 address
ansible.builtin.debug:
msg: "{{ query('community.dns.reverse_lookup', '192.168.1.1') }}"
- name: Look up hostname of IPv6 address
ansible.builtin.debug:
msg: "{{ query('community.dns.reverse_lookup', '1:2:3::4') }}"
Return Value
Key |
Description |
---|---|
The hostname(s) returned for the queried IP addresses. If multiple IP addresses are queried in Returned: success Sample: |