ansible ad-hoc cli command does not respect ANSIBLE_STDOUT_CALLBACK

I just raised this issue with Ansible which has been immediately closed.

https://github.com/ansible/ansible/issues/16194

I’m going to copy / paste my report verbatim so as to avoid repeating myself all over again (hopefully the formatting doesn’t screw up).

ISSUE TYPE- Bug Report
ANSIBLE VERSION
ansible 2.2.0 (devel 3bac945147) last updated 2016/06/03 21:47:13 (GMT +100)
  lib/ansible/modules/core: (detached HEAD 2bd8d78a8b) last updated 2016/06/04 08:22:55 (GMT +100)
  lib/ansible/modules/extras: (detached HEAD b0aec50b9a) last updated 2016/06/04 08:23:00 (GMT +100)
  config file = /home/john/git/ansible-dsh/tests/ansible.cfg
  configured module search path = Default w/o overrides

CONFIGURATION

export ANSIBLE_STDOUT_CALLBACK=dsh

OS / ENVIRONMENT

N/A

SUMMARY

The Ansible ad-hoc CLI command (simply called ansible) does not respect the setting of the ANSIBLE_STDOUT_CALLBACK environment variable. This makes it impossible to customise the output using my own callback plugin.

For example, I have written a callback plugin called dsh (a development version can be found here) which formats output in a similar fashion to the distributed shell command.

STEPS TO REPRODUCE