From 76be7b5db558d2ee7c1f19f4d3b88e85052ec710 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Mon, 22 Jan 2018 21:58:43 +0100 Subject: [PATCH] forgot resolve filter --- .gitignore | 1 + filter_plugins/resolve_filter.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 filter_plugins/resolve_filter.py 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))