mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #3018 from dsedivec/devel
Plug-ins loaded from top-level plug-in directory
This commit is contained in:
commit
5fdca267ac
5 changed files with 46 additions and 3 deletions
|
@ -101,7 +101,6 @@ class PluginLoader(object):
|
|||
for file in files:
|
||||
if os.path.isdir(file) and file not in ret:
|
||||
ret.append(file)
|
||||
else:
|
||||
if fullpath not in ret:
|
||||
ret.append(fullpath)
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ class TestRunner(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.user = getpass.getuser()
|
||||
self.runner = ansible.runner.Runner(
|
||||
basedir='test/',
|
||||
module_name='ping',
|
||||
module_path='library/',
|
||||
module_args='',
|
||||
|
@ -77,6 +78,12 @@ class TestRunner(unittest.TestCase):
|
|||
assert "localhost" in results['contacted']
|
||||
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):
|
||||
result = self._run('ping', [])
|
||||
assert "ping" in result
|
||||
|
|
15
test/action_plugins/categorized_plugin.py
Normal file
15
test/action_plugins/categorized_plugin.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
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"})
|
11
test/action_plugins/category/categorized_plugin.py
Normal file
11
test/action_plugins/category/categorized_plugin.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
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"})
|
11
test/action_plugins/uncategorized_plugin.py
Normal file
11
test/action_plugins/uncategorized_plugin.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
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"})
|
Loading…
Reference in a new issue