issue #164: add action module to return active strategy.

pull/193/head
David Wilson 7 years ago
parent 0247561fc7
commit 48a0938d04

@ -2,6 +2,7 @@
inventory = hosts inventory = hosts
gathering = explicit gathering = explicit
strategy_plugins = ../../ansible_mitogen/plugins/strategy strategy_plugins = ../../ansible_mitogen/plugins/strategy
action_plugins = lib/action
library = lib/modules library = lib/modules
retry_files_enabled = False retry_files_enabled = False
forks = 50 forks = 50

@ -0,0 +1,25 @@
import sys
from ansible.plugins.strategy import StrategyBase
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def _get_strategy_name(self):
frame = sys._getframe()
while frame:
st = frame.f_locals.get('self')
if isinstance(st, StrategyBase):
return '%s.%s' % (type(st).__module__, type(st).__name__)
frame = frame.f_back
return ''
def run(self, tmp=None, task_vars=None):
return {
'changed': False,
'ansible_facts': {
'strategy': self._get_strategy_name(),
'is_mitogen': 'ansible_mitogen' in self._get_strategy_name(),
}
}
Loading…
Cancel
Save