From 0aa76503dc706340d85f4d3f19f472880187eb14 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 13 May 2020 12:02:31 -0400 Subject: [PATCH] avoid fatal tb on bad fqcn callback name (#69440) --- changelogs/fragments/no_fatal_bad_cb.yml | 2 ++ lib/ansible/executor/task_queue_manager.py | 7 +++++-- test/integration/targets/collections/runme.sh | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/no_fatal_bad_cb.yml diff --git a/changelogs/fragments/no_fatal_bad_cb.yml b/changelogs/fragments/no_fatal_bad_cb.yml new file mode 100644 index 00000000000..be67eeab2a8 --- /dev/null +++ b/changelogs/fragments/no_fatal_bad_cb.yml @@ -0,0 +1,2 @@ +bugfixes: + - avoid fatal traceback when a bad FQCN for a callback is supplied in the whitelist (#69401). diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 30c5f383a67..cd6c396860c 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -162,8 +162,11 @@ class TaskQueueManager: for callback_plugin_name in (c for c in C.DEFAULT_CALLBACK_WHITELIST if AnsibleCollectionRef.is_valid_fqcr(c)): # TODO: need to extend/duplicate the stdout callback check here (and possible move this ahead of the old way callback_obj = callback_loader.get(callback_plugin_name) - callback_obj.set_options() - self._callback_plugins.append(callback_obj) + if callback_obj: + callback_obj.set_options() + self._callback_plugins.append(callback_obj) + else: + display.warning("Skipping '%s', unable to load or use as a callback" % callback_plugin_name) self._callbacks_loaded = True diff --git a/test/integration/targets/collections/runme.sh b/test/integration/targets/collections/runme.sh index 5a82acc4e62..5aea771bdaf 100755 --- a/test/integration/targets/collections/runme.sh +++ b/test/integration/targets/collections/runme.sh @@ -71,3 +71,6 @@ if [[ "$(grep -wc "dynamic_host_a" "$CACHEFILE")" -ne "0" ]]; then fi ./vars_plugin_tests.sh + +# ensure non existing callback does not crash ansible +ANSIBLE_CALLBACK_WHITELIST=charlie.gomez.notme ansible -m ping localhost