forked from FF-RGB/ansible
forgot resolve filter
This commit is contained in:
parent
8d92dc9c82
commit
76be7b5db5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.vault_pass
|
||||
__pycache__
|
||||
site.retry
|
||||
|
16
filter_plugins/resolve_filter.py
Normal file
16
filter_plugins/resolve_filter.py
Normal 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))
|
Loading…
Reference in New Issue
Block a user