|
|
@ -19,6 +19,7 @@ __metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.errors import AnsibleError
|
|
|
|
from ansible.errors import AnsibleError
|
|
|
|
from ansible.plugins.lookup import LookupBase
|
|
|
|
from ansible.plugins.lookup import LookupBase
|
|
|
|
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
import socket
|
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -143,7 +144,7 @@ class LookupModule(LookupBase):
|
|
|
|
nsaddr = dns.resolver.query(ns)[0].address
|
|
|
|
nsaddr = dns.resolver.query(ns)[0].address
|
|
|
|
nameservers.append(nsaddr)
|
|
|
|
nameservers.append(nsaddr)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
raise AnsibleError("dns lookup NS: ", str(e))
|
|
|
|
raise AnsibleError("dns lookup NS: %s" % to_native(e))
|
|
|
|
myres.nameservers = nameservers
|
|
|
|
myres.nameservers = nameservers
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
if '=' in t:
|
|
|
|
if '=' in t:
|
|
|
@ -156,6 +157,11 @@ class LookupModule(LookupBase):
|
|
|
|
qtype = arg.upper()
|
|
|
|
qtype = arg.upper()
|
|
|
|
elif opt == 'flat':
|
|
|
|
elif opt == 'flat':
|
|
|
|
flat = int(arg)
|
|
|
|
flat = int(arg)
|
|
|
|
|
|
|
|
elif opt == 'class':
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
rdclass = dns.rdataclass.from_text(arg)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
raise AnsibleError("dns lookup illegal CLASS: %s" % to_native(e))
|
|
|
|
|
|
|
|
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
@ -178,7 +184,7 @@ class LookupModule(LookupBase):
|
|
|
|
except dns.exception.SyntaxError:
|
|
|
|
except dns.exception.SyntaxError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
raise AnsibleError("dns.reversename unhandled exception", str(e))
|
|
|
|
raise AnsibleError("dns.reversename unhandled exception %s" % to_native(e))
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
answers = myres.query(domain, qtype)
|
|
|
|
answers = myres.query(domain, qtype)
|
|
|
@ -207,6 +213,6 @@ class LookupModule(LookupBase):
|
|
|
|
except dns.resolver.Timeout:
|
|
|
|
except dns.resolver.Timeout:
|
|
|
|
ret.append('')
|
|
|
|
ret.append('')
|
|
|
|
except dns.exception.DNSException as e:
|
|
|
|
except dns.exception.DNSException as e:
|
|
|
|
raise AnsibleError("dns.resolver unhandled exception", e)
|
|
|
|
raise AnsibleError("dns.resolver unhandled exception %s" % to_native(e))
|
|
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|