diff --git a/.gitignore b/.gitignore index 9580ccb..bb9c50d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vault_pass +__pycache__ site.retry diff --git a/filter_plugins/resolve_filter.py b/filter_plugins/resolve_filter.py new file mode 100644 index 0000000..3ebe9e2 --- /dev/null +++ b/filter_plugins/resolve_filter.py @@ -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))