File: determine_strategy.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (24 lines) | stat: -rw-r--r-- 724 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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(),
            }
        }