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
export ANSIBLE_STDOUT_CALLBACK=dsh
N/A
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.
mkdir callback_plugins
# copy my custom dsh.py plugin into the `callback_plugins` directory
export ANSIBLE_STDOUT_CALLBACK=myplugin
export ANSIBLE_HOST_KEY_CHECKING=False
ansible -i hosts all -m ping
I expect my dsh plugin to be used, to create output as follows:
host1: Wed Jun 8 19:55:49 UTC 2016
host2: Wed Jun 8 19:55:49 UTC 2016
The usual minimal plugin is used instead.
host1 | SUCCESS | rc=0 >>
Wed Jun 8 19:55:35 UTC 2016
host2 | SUCCESS | rc=0 >>
Wed Jun 8 19:55:35 UTC 2016
In any case, this is by design, there is an additional setting (bin_ansible_callbacks) to specifically force it to do so.
if self.callback:
cb = self.callback
elif self.options.one_line:
cb = 'oneline'
else:
cb = 'minimal'
if self.callback:
cb = self.callback
elif self.options.one_line:
cb = 'oneline'
else:
from ansible.compat.six.moves import configparser
cb = C.get_config(configparser.ConfigParser, 'defaults', 'stdout_callback',
'ANSIBLE_STDOUT_CALLBACK', 'minimal')