Skip to content

Commit

Permalink
allow using other stdout callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Nov 12, 2019
1 parent a636dfa commit 15a0814
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ansible_runner/callbacks/awx_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@
# match "CallbackModule"
class CallbackModule(AWXDefaultCallbackModule):
pass


if hasattr(CallbackModule, 'PROXY_DOCUMENTATION'):
DOCUMENTATION = CallbackModule.PROXY_DOCUMENTATION
14 changes: 12 additions & 2 deletions ansible_runner/display_callback/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@
import collections
import contextlib
import sys
import os
import importlib
import uuid
from copy import copy

# Ansible
from ansible import constants as C
from ansible.plugins.callback import CallbackBase
from ansible.plugins.callback.default import CallbackModule as DefaultCallbackModule

# AWX Display Callback
from .events import event_context
from .minimal import CallbackModule as MinimalCallbackModule


if 'RUNNER_STDOUT_CALLBACK_PROXY' in os.environ:
from ansible.plugins.loader import callback_loader
DefaultCallbackModule = callback_loader.get(os.environ['RUNNER_STDOUT_CALLBACK_PROXY']).__class__
DefaultCallbackModule.PROXY_DOCUMENTATION = importlib.import_module(DefaultCallbackModule.__module__).DOCUMENTATION
else:
from ansible.plugins.callback.default import CallbackModule as DefaultCallbackModule


CENSORED = "the output has been hidden due to the fact that 'no_log: true' was specified for this result" # noqa


Expand Down Expand Up @@ -271,7 +281,7 @@ def v2_playbook_on_task_start(self, task, is_conditional):
uuid=task_uuid,
)
with self.capture_event_data('playbook_on_task_start', **event_data):
super(BaseCallbackModule, self).v2_playbook_on_task_start(task, is_conditional)
super(BaseCallbackModule, self).v2_playbook_on_task_start(task, is_conditional=is_conditional)

def v2_playbook_on_cleanup_task_start(self, task):
# NOTE: Not used by Ansible 2.x.
Expand Down
3 changes: 3 additions & 0 deletions ansible_runner/runner_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ def prepare(self):
if python_path and not python_path.endswith(':'):
python_path += ':'
self.env['ANSIBLE_CALLBACK_PLUGINS'] = ':'.join(filter(None,(self.env.get('ANSIBLE_CALLBACK_PLUGINS'), callback_dir)))
# If stdout callback specified, pass info for this stdout callback plugin to subclass it
if 'ANSIBLE_STDOUT_CALLBACK' in self.env and self.env['ANSIBLE_STDOUT_CALLBACK'] not in ('awx_display', 'minimal'):
self.env['RUNNER_STDOUT_CALLBACK_PROXY'] = self.env['ANSIBLE_STDOUT_CALLBACK']
if 'AD_HOC_COMMAND_ID' in self.env:
self.env['ANSIBLE_STDOUT_CALLBACK'] = 'minimal'
else:
Expand Down

0 comments on commit 15a0814

Please sign in to comment.