ansible-ffrgb/filter_plugins/resolve_filter.py

17 lines
433 B
Python
Raw Normal View History

2018-01-22 21:58:43 +01:00
# Install dependencies:
# apt-get install python-dnspython python3-dnspython
2018-01-22 21:58:43 +01:00
import dns.resolver
class FilterModule (object):
def filters(self):
return {
"resolve": self.resolve,
}
def resolve(self, hostname, rrtype):
answers = dns.resolver.query(hostname, rrtype)
for data in answers:
return data.address
raise errors.AnsibleFilterError('unable to get %s record for: %s' % (rrtype, hostname))