-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runner 2.2 breaks callbacks that use get_option
#1077
Comments
2.2+ breaks our callback tests: Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/ansible-playbook", line 123, in <module> exit_code = cli.run() File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/cli/playbook.py", line 128, in run results = pbex.run() File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/executor/playbook_executor.py", line 99, in run self._tqm.load_callbacks() File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 137, in load_callbacks self._stdout_callback.set_options() File "/home/runner/work/foreman-ansible-modules/foreman-ansible-modules/build/collections/ansible_collections/theforeman/foreman/plugins/callback/foreman.py", line 191, in set_options if self.get_option('disable_callback'): File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option return self._plugin_options[k] KeyError: 'disable_callback' See: https://github.com/ansible/ansible-runner/issues/1074
2.2+ breaks our callback tests: Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/ansible-playbook", line 123, in <module> exit_code = cli.run() File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/cli/playbook.py", line 128, in run results = pbex.run() File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/executor/playbook_executor.py", line 99, in run self._tqm.load_callbacks() File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 137, in load_callbacks self._stdout_callback.set_options() File "/home/runner/work/foreman-ansible-modules/foreman-ansible-modules/build/collections/ansible_collections/theforeman/foreman/plugins/callback/foreman.py", line 191, in set_options if self.get_option('disable_callback'): File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option return self._plugin_options[k] KeyError: 'disable_callback' See: https://github.com/ansible/ansible-runner/issues/1074
@shanemcd @AlanCoding This seems to be an issue with the |
The backtrace does contain the right |
I don't think In these cases you still need to set |
This comment was marked as off-topic.
This comment was marked as off-topic.
This is most certainly a runner bug. The problem is that the This means that the Here is a POC that fixes the issue: Expand Patch...
diff --git a/ansible_runner/display_callback/callback/awx_display.py b/ansible_runner/display_callback/callback/awx_display.py
index 79a56f9..10fe3ac 100644
--- a/ansible_runner/display_callback/callback/awx_display.py
+++ b/ansible_runner/display_callback/callback/awx_display.py
@@ -61,7 +61,7 @@ elif IS_ADHOC:
else:
default_stdout_callback = 'default'
-DefaultCallbackModule = callback_loader.get(default_stdout_callback).__class__
+DefaultCallbackModule = callback_loader.get(default_stdout_callback, class_only=True)
CENSORED = "the output has been hidden due to the fact that 'no_log: true' was specified for this result"
@@ -348,6 +348,16 @@ class CallbackModule(DefaultCallbackModule):
self.play_uuids = set()
self.duplicate_play_counts = collections.defaultdict(lambda: 1)
+ def set_options(self, task_keys=None, var_options=None, direct=None):
+ base_config = C.config.get_configuration_definition(DefaultCallbackModule._load_name, plugin_type='callback')
+ my_config = C.config.get_configuration_definition(self._load_name, plugin_type='callback')
+ C.config.initialize_plugin_configuration_definitions('callback', self._load_name, base_config | my_config)
+ return super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
+
@contextlib.contextmanager
def capture_event_data(self, event, **event_data):
event_data.setdefault('uuid', str(uuid.uuid4())) |
patch looks good, though i might reverse the order depending on which options you want to have precedence in a conflict case |
I don't disagree with the patch, but I lack a genuine test case. The command:
Results in no output and the data saved to
Results in normal stdout and the same data saved to I can find no example of a stdout callback that sets non-default options. |
fwiw, this was how I tested with just ansible core: export ANSIBLE_CALLBACKS_ENABLED=tree,awx_display
export ANSIBLE_STDOUT_CALLBACK=awx_display
export ORIGINAL_STDOUT_CALLBACK=tree
export AWX_ISOLATED_DATA_DIR=$PWD/cache
mkdir -p $AWX_ISOLATED_DATA_DIR
RUNNER=$PWD/ansible-runner/ansible_runner
if [ -e "${RUNNER}/callbacks" ]; then
export ANSIBLE_CALLBACK_PLUGINS=${RUNNER}/callbacks
else
export ANSIBLE_CALLBACK_PLUGINS=${RUNNER}/display_callback/callback
fi
ansible-playbook -vvv 77819.yml |
iirc, this one should have non standard options only |
To load options, callback plugins can use `get_option` api. Allow this functionality for other callback plugin. Fixes: ansible#1077 Signed-off-by: Abhijeet Kasurde <[email protected]>
Ohai,
ansible runner 2.2.0 breaks runs that use callbacks which utilize
get_option
to load options, like thetree
callback in ansible-core.Running the above Python code results in:
And with increased verbosity:
Downgrading to ansible-runner-2.1.3 makes the same code work again.
The text was updated successfully, but these errors were encountered: