Commit 5fdca267 by Michael DeHaan

Merge pull request #3018 from dsedivec/devel

Plug-ins loaded from top-level plug-in directory
parents fd9bbeb4 611d56dc
...@@ -100,11 +100,10 @@ class PluginLoader(object): ...@@ -100,11 +100,10 @@ class PluginLoader(object):
files = glob.glob("%s/*" % fullpath) files = glob.glob("%s/*" % fullpath)
for file in files: for file in files:
if os.path.isdir(file) and file not in ret: if os.path.isdir(file) and file not in ret:
ret.append(file) ret.append(file)
else:
if fullpath not in ret: if fullpath not in ret:
ret.append(fullpath) ret.append(fullpath)
# look in any configured plugin paths, allow one level deep for subcategories # look in any configured plugin paths, allow one level deep for subcategories
configured_paths = self.config.split(os.pathsep) configured_paths = self.config.split(os.pathsep)
for path in configured_paths: for path in configured_paths:
......
...@@ -27,6 +27,7 @@ class TestRunner(unittest.TestCase): ...@@ -27,6 +27,7 @@ class TestRunner(unittest.TestCase):
def setUp(self): def setUp(self):
self.user = getpass.getuser() self.user = getpass.getuser()
self.runner = ansible.runner.Runner( self.runner = ansible.runner.Runner(
basedir='test/',
module_name='ping', module_name='ping',
module_path='library/', module_path='library/',
module_args='', module_args='',
...@@ -77,6 +78,12 @@ class TestRunner(unittest.TestCase): ...@@ -77,6 +78,12 @@ class TestRunner(unittest.TestCase):
assert "localhost" in results['contacted'] assert "localhost" in results['contacted']
return results['contacted']['localhost'] return results['contacted']['localhost']
def test_action_plugins(self):
result = self._run("uncategorized_plugin", [])
assert result.get("msg") == "uncategorized"
result = self._run("categorized_plugin", [])
assert result.get("msg") == "categorized"
def test_ping(self): def test_ping(self):
result = self._run('ping', []) result = self._run('ping', [])
assert "ping" in result assert "ping" in result
......
from ansible.runner import return_data
class ActionModule (object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, module_args, inject,
complex_args=None, **kwargs):
# This plug-in should be ignored in deference to
# category/categorized_plugin.py, so it should never actually
# run.
return return_data.ReturnData(
conn=conn, comm_ok=True,
result={"msg": "this plug-in should never be run"})
from ansible.runner import return_data
class ActionModule (object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, module_args, inject,
complex_args=None, **kwargs):
return return_data.ReturnData(conn=conn, comm_ok=True,
result={"msg": "categorized"})
from ansible.runner import return_data
class ActionModule (object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, module_args, inject,
complex_args=None, **kwargs):
return return_data.ReturnData(conn=conn, comm_ok=True,
result={"msg": "uncategorized"})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment