From 663d37b53706c40aa88816dede2552c4d782974d Mon Sep 17 00:00:00 2001 From: "C. Morgan Hamill" Date: Wed, 17 Apr 2013 11:06:15 -0400 Subject: [PATCH] Fix errors in lookup plugins. Lookup plugins 'sequence' and 'template' now import 'ansible.utils' appropriately in order to use the 'listify_lookup_plugin_terms' function. Also, 'dnstxt' and 'env' now check to see if 'terms' is a string; without this calls like '{{ lookup('env', 'HOME') }}' fail. --- lib/ansible/runner/lookup_plugins/dnstxt.py | 4 ++-- lib/ansible/runner/lookup_plugins/env.py | 3 +++ lib/ansible/runner/lookup_plugins/fileglob.py | 2 +- lib/ansible/runner/lookup_plugins/sequence.py | 4 ++-- lib/ansible/runner/lookup_plugins/template.py | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ansible/runner/lookup_plugins/dnstxt.py b/lib/ansible/runner/lookup_plugins/dnstxt.py index 7c56d8a00b..28ec2e7b61 100644 --- a/lib/ansible/runner/lookup_plugins/dnstxt.py +++ b/lib/ansible/runner/lookup_plugins/dnstxt.py @@ -44,8 +44,8 @@ class LookupModule(object): terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject) - - + if isinstance(basestring, terms): + terms = [ terms ] ret = [] for term in terms: diff --git a/lib/ansible/runner/lookup_plugins/env.py b/lib/ansible/runner/lookup_plugins/env.py index bd0fc4f6d9..86b1da5aaa 100644 --- a/lib/ansible/runner/lookup_plugins/env.py +++ b/lib/ansible/runner/lookup_plugins/env.py @@ -27,6 +27,9 @@ class LookupModule(object): terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject) + if isinstance(basestring, terms): + terms = [ terms ] + ret = [] for term in terms: var = term.split()[0] diff --git a/lib/ansible/runner/lookup_plugins/fileglob.py b/lib/ansible/runner/lookup_plugins/fileglob.py index 2dd2342d26..254f48bec7 100644 --- a/lib/ansible/runner/lookup_plugins/fileglob.py +++ b/lib/ansible/runner/lookup_plugins/fileglob.py @@ -26,7 +26,7 @@ class LookupModule(object): def run(self, terms, inject=None, **kwargs): - utils.listify_lookup_plugin_terms(terms, self.basedir, inject) + terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject) ret = [] diff --git a/lib/ansible/runner/lookup_plugins/sequence.py b/lib/ansible/runner/lookup_plugins/sequence.py index ef07417fc8..8d70aad98c 100644 --- a/lib/ansible/runner/lookup_plugins/sequence.py +++ b/lib/ansible/runner/lookup_plugins/sequence.py @@ -16,7 +16,7 @@ # along with Ansible. If not, see . from ansible.errors import AnsibleError -from ansible.utils import parse_kv +import ansible.utils as utils from re import compile as re_compile, IGNORECASE # shortcut format @@ -181,7 +181,7 @@ class LookupModule(object): try: if not self.parse_simple_args(term): - self.parse_kv_args(parse_kv(term)) + self.parse_kv_args(utils.parse_kv(term)) except Exception: raise AnsibleError( "unknown error parsing with_sequence arguments: %r" diff --git a/lib/ansible/runner/lookup_plugins/template.py b/lib/ansible/runner/lookup_plugins/template.py index f1d877797a..e009b6b76b 100644 --- a/lib/ansible/runner/lookup_plugins/template.py +++ b/lib/ansible/runner/lookup_plugins/template.py @@ -16,6 +16,7 @@ # along with Ansible. If not, see . from ansible.utils import template +import ansible.utils as utils class LookupModule(object):