diff options
author | James Tanner <tanner.jc@gmail.com> | 2013-11-25 10:57:10 -0500 |
---|---|---|
committer | James Tanner <tanner.jc@gmail.com> | 2013-11-25 10:57:10 -0500 |
commit | b8146e3bc73d779b6e5ddf103d78a55680705637 (patch) | |
tree | f0d41a562a2878fadea85b22f0bd7837d9d1569c | |
parent | 903c4cae7b0bf68aa259367c3b64e96bbddb7730 (diff) | |
download | ansible-b8146e3bc73d779b6e5ddf103d78a55680705637.tar.gz |
Fixes #4979 Check for the correct context when inside the inventory_hostnames plugin
-rw-r--r-- | lib/ansible/runner/lookup_plugins/inventory_hostnames.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/runner/lookup_plugins/inventory_hostnames.py b/lib/ansible/runner/lookup_plugins/inventory_hostnames.py index 6880887d84..98523e1398 100644 --- a/lib/ansible/runner/lookup_plugins/inventory_hostnames.py +++ b/lib/ansible/runner/lookup_plugins/inventory_hostnames.py @@ -34,7 +34,10 @@ class LookupModule(object): def __init__(self, basedir=None, **kwargs): self.basedir = basedir - self.host_list = kwargs['runner'].inventory.host_list + if 'runner' in kwargs: + self.host_list = kwargs['runner'].inventory.host_list + else: + raise errors.AnsibleError("inventory_hostnames must be used as a loop. Example: \"with_inventory_hostnames: \'all\'\"") def run(self, terms, inject=None, **kwargs): terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject) |