You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mitogen/tests/ansible/lib/action/mitogen_action_script.py

29 lines
660 B
Python

# I am an Ansible action plug-in. I run the script provided in the parameter in
# the context of the action.
import sys
from ansible.plugins.action import ActionBase
def execute(s, gbls, lcls):
if sys.version_info > (3,):
exec(s, gbls, lcls)
else:
exec('exec s in gbls, lcls')
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
super(ActionModule, self).run(tmp=tmp, task_vars=task_vars)
lcls = {
'self': self,
'result': {}
}
execute(self._task.args['script'], globals(), lcls)
return lcls['result']
if __name__ == '__main__':
main()