forgot resolve filter

This commit is contained in:
Markus 2018-01-22 21:58:43 +01:00
parent 8d92dc9c82
commit 76be7b5db5
2 changed files with 17 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.vault_pass
__pycache__
site.retry

View File

@ -0,0 +1,16 @@
# Install dependencies:
# apt-get install python-dnspython
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))