Open evgeni opened 2 years ago
@shanemcd @AlanCoding This seems to be an issue with the awx_display
callback since it overrides the original callback being specified.
The backtrace does contain the right ansible/plugins/callback/tree.py
tho?
I don't think ANSIBLE_STDOUT_CALLBACK
is right, because "tree" is not a standard out callback. It saves the data to files, it doesn't output it to the console. You can see it in the plugin code CALLBACK_TYPE = 'aggregate'
, not CALLBACK_TYPE = 'stdout'
.
In these cases you still need to set ANSIBLE_CALLBACKS_ENABLED
. I still don't know how to make your script work correctly, but there's not necessarily an ansible-runner bug.
@evgeni: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.
Here are the items we could not find in your description:
Please set the description of this issue with an appropriate template from: https://github.com/ansible/ansible/tree/devel/.github/ISSUE_TEMPLATE
This is most certainly a runner bug. The problem is that the DOCUMENTATION
for awx_display
only extends from default_callback
and the fact that there is dynamic class building means that the config defs for the inherited callback are not included in the config defs of the awx_display
callback.
This means that the awx_display
as is can currently only utilize a callback that is effectively the default
callback.
Here is a POC that fixes the issue:
```diff 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:
ANSIBLE_CALLBACKS_ENABLED=tree ANSIBLE_STDOUT_CALLBACK=tree ansible-playbook -i localhost, ping.yml --connection=local
Results in no output and the data saved to ~/.ansible/tree
. It is somewhat surprising that it runs.
ANSIBLE_CALLBACKS_ENABLED=tree ansible-playbook -i localhost, ping.yml --connection=local
Results in normal stdout and the same data saved to ~/.ansible/tree
.
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 https://docs.ansible.com/ansible/latest/collections/community/general/selective_callback.html
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.