Skip to content

Commit 39644c6

Browse files
Merge pull request #327 from pguermo/master
Keep the callback provided in the environment variable Reviewed-by: https://github.com/apps/ansible-zuul
2 parents 732efec + 89cf573 commit 39644c6

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

ansible_runner/runner_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def prepare(self):
176176
python_path = self.env.get('PYTHONPATH', os.getenv('PYTHONPATH', ''))
177177
if python_path and not python_path.endswith(':'):
178178
python_path += ':'
179-
self.env['ANSIBLE_CALLBACK_PLUGINS'] = callback_dir
179+
self.env['ANSIBLE_CALLBACK_PLUGINS'] = ':'.join(filter(None,(self.env.get('ANSIBLE_CALLBACK_PLUGINS'), callback_dir)))
180180
if 'AD_HOC_COMMAND_ID' in self.env:
181181
self.env['ANSIBLE_STDOUT_CALLBACK'] = 'minimal'
182182
else:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from ansible.plugins.callback import CallbackBase
2+
3+
4+
class CallbackModule(CallbackBase):
5+
CALLBACK_VERSION = 2.0
6+
CALLBACK_TYPE = 'aggregate'
7+
CALLBACK_NAME = 'other_callback'
8+
9+
def v2_playbook_on_play_start(self, play):
10+
pass
11+
12+
def v2_runner_on_ok(self, result):
13+
pass
14+

test/integration/test_display_callback.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,22 @@
1111

1212
import pytest
1313

14+
HERE = os.path.abspath(os.path.dirname(__file__))
15+
1416

1517
@pytest.fixture()
1618
def executor(tmpdir, request):
1719
private_data_dir = six.text_type(tmpdir.mkdir('foo'))
1820

1921
playbooks = request.node.callspec.params.get('playbook')
2022
playbook = list(playbooks.values())[0]
23+
envvars = request.node.callspec.params.get('envvars')
24+
envvars = envvars.update({"ANSIBLE_DEPRECATION_WARNINGS": "False"}) if envvars is not None else {"ANSIBLE_DEPRECATION_WARNINGS": "False"}
2125

2226
r = init_runner(
2327
private_data_dir=private_data_dir,
2428
inventory="localhost ansible_connection=local",
25-
envvars={"ANSIBLE_DEPRECATION_WARNINGS": "False"},
29+
envvars=envvars,
2630
playbook=yaml.safe_load(playbook)
2731
)
2832

@@ -57,7 +61,11 @@ def executor(tmpdir, request):
5761
var: results
5862
'''}, # noqa
5963
])
60-
def test_callback_plugin_receives_events(executor, event, playbook):
64+
@pytest.mark.parametrize('envvars', [
65+
{'ANSIBLE_CALLBACK_PLUGINS': os.path.join(HERE, 'callback')},
66+
{'ANSIBLE_CALLBACK_PLUGINS': ''}
67+
])
68+
def test_callback_plugin_receives_events(executor, event, playbook, envvars):
6169
executor.run()
6270
assert len(list(executor.events))
6371
assert event in [task['event'] for task in executor.events]

0 commit comments

Comments
 (0)