summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Tanner <tanner.jc@gmail.com>2013-11-25 10:57:10 -0500
committerJames Tanner <tanner.jc@gmail.com>2013-11-25 10:57:10 -0500
commitb8146e3bc73d779b6e5ddf103d78a55680705637 (patch)
treef0d41a562a2878fadea85b22f0bd7837d9d1569c
parent903c4cae7b0bf68aa259367c3b64e96bbddb7730 (diff)
downloadansible-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.py5
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)