|
|
|
@ -37,9 +37,15 @@ import mitogen.utils
|
|
|
|
|
|
|
|
|
|
import ansible.errors
|
|
|
|
|
import ansible.plugins.strategy.linear
|
|
|
|
|
import ansible.plugins
|
|
|
|
|
import ansible_mitogen.mixins
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from ansible.plugins.loader import action_loader
|
|
|
|
|
from ansible.plugins.loader import connection_loader
|
|
|
|
|
except ImportError: # Ansible <2.4
|
|
|
|
|
from ansible.plugins import action_loader
|
|
|
|
|
from ansible.plugins import connection_loader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def wrap_action_loader__get(name, *args, **kwargs):
|
|
|
|
|
"""
|
|
|
|
@ -217,19 +223,19 @@ class StrategyModule(ansible.plugins.strategy.linear.StrategyModule):
|
|
|
|
|
with references to the real functions.
|
|
|
|
|
"""
|
|
|
|
|
global action_loader__get
|
|
|
|
|
action_loader__get = ansible.plugins.action_loader.get
|
|
|
|
|
ansible.plugins.action_loader.get = wrap_action_loader__get
|
|
|
|
|
action_loader__get = action_loader.get
|
|
|
|
|
action_loader.get = wrap_action_loader__get
|
|
|
|
|
|
|
|
|
|
global connection_loader__get
|
|
|
|
|
connection_loader__get = ansible.plugins.connection_loader.get
|
|
|
|
|
ansible.plugins.connection_loader.get = wrap_connection_loader__get
|
|
|
|
|
connection_loader__get = connection_loader.get
|
|
|
|
|
connection_loader.get = wrap_connection_loader__get
|
|
|
|
|
|
|
|
|
|
def _remove_wrappers(self):
|
|
|
|
|
"""
|
|
|
|
|
Uninstall the PluginLoader monkey patches.
|
|
|
|
|
"""
|
|
|
|
|
ansible.plugins.action_loader.get = action_loader__get
|
|
|
|
|
ansible.plugins.connection_loader.get = connection_loader__get
|
|
|
|
|
action_loader.get = action_loader__get
|
|
|
|
|
connection_loader.get = connection_loader__get
|
|
|
|
|
|
|
|
|
|
def _add_connection_plugin_path(self):
|
|
|
|
|
"""
|
|
|
|
@ -239,7 +245,7 @@ class StrategyModule(ansible.plugins.strategy.linear.StrategyModule):
|
|
|
|
|
# ansible_mitogen base directory:
|
|
|
|
|
basedir = os.path.dirname(os.path.dirname(__file__))
|
|
|
|
|
conn_dir = os.path.join(basedir, 'connection')
|
|
|
|
|
ansible.plugins.connection_loader.add_directory(conn_dir)
|
|
|
|
|
connection_loader.add_directory(conn_dir)
|
|
|
|
|
|
|
|
|
|
def run(self, iterator, play_context, result=0):
|
|
|
|
|
self._add_connection_plugin_path()
|
|
|
|
|