ANSIBLE_STDOUT_CALLBACK json with Ansible 2.9

Hi All,

For reasons of extreme inertia, for certain use cases Ansible 2.9.27 is used in my organisation, something I’m working to change but it is what it is. I have seen when I set ANSIBLE_STDOUT_CALLBACK to “json” while the output is produced as expected in JSON format but this output only appears when the playbook is over. However when I revert to default or set ANSIBLE_STDOUT_CALLBACK to “yaml”, the output comes task by task.

I would like to get JSON output, but to appear as each task is executed as it does with ANSIBLE_STDOUT_CALLBACK=YAML. Is there anything I can do to effect this, while continuing to use this version of Ansible?

That is just the way the plugin works, to give a full parsable JSON as the stdout at the conclusion of the execution. If you want a different behavior you would need to write a custom callback plugin.

For what it is worth, the yaml callback doesn’t actually produce full parsable yaml output, or if you find it does, it is coincidental, and not intended.

However, to get a JSON version of the YAML callback, just use the default callback.

1 Like

Thanks for your explanation.