|
|
@ -20,6 +20,7 @@ import os
|
|
|
|
HAVE_DNS=False
|
|
|
|
HAVE_DNS=False
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import dns.resolver
|
|
|
|
import dns.resolver
|
|
|
|
|
|
|
|
from dns.exception import DNSException
|
|
|
|
HAVE_DNS=True
|
|
|
|
HAVE_DNS=True
|
|
|
|
except ImportError:
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -43,9 +44,17 @@ class LookupModule(object):
|
|
|
|
|
|
|
|
|
|
|
|
domain = terms.split()[0]
|
|
|
|
domain = terms.split()[0]
|
|
|
|
string = []
|
|
|
|
string = []
|
|
|
|
answers = dns.resolver.query(domain, 'TXT')
|
|
|
|
try:
|
|
|
|
for rdata in answers:
|
|
|
|
answers = dns.resolver.query(domain, 'TXT')
|
|
|
|
s = rdata.to_text()
|
|
|
|
for rdata in answers:
|
|
|
|
string.append(s[1:-1]) # Strip outside quotes on TXT rdata
|
|
|
|
s = rdata.to_text()
|
|
|
|
|
|
|
|
string.append(s[1:-1]) # Strip outside quotes on TXT rdata
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except dns.resolver.NXDOMAIN:
|
|
|
|
|
|
|
|
string = 'NXDOMAIN'
|
|
|
|
|
|
|
|
except dns.resolver.Timeout:
|
|
|
|
|
|
|
|
string = ''
|
|
|
|
|
|
|
|
except dns.exception.DNSException as e:
|
|
|
|
|
|
|
|
raise errors.AnsibleError("dns.resolver unhandled exception", e)
|
|
|
|
|
|
|
|
|
|
|
|
return ''.join(string)
|
|
|
|
return ''.join(string)
|
|
|
|