This is an open discussion, since I’m far from an expert on ansible.
However, since I often run some commands on a lot of host, I’ve written a small callback plugin that summarize output on stdout and stderr.
I need this callback to be called when running ansible (not the playbook), since I only run once a command, and forget it after that.
So I copied the “callbacks.load_callback_
plugins()” from ansible-playbook. See the GitHub pull request to see it.
To avoid breaking user experience that are not used to callback in the ansible command, it may be a good idea to implement as an option, e.g. “ansible --callbacks …”
I hope to gather comments on this
Adrien
So, before, callback plugins were not loaded for /usr/bin/ansible.
I would rather not expand ansible’s CLI options in this case.
The question though, is more of one for users of existing custom callback plugins - if using something like the Hipchat example callback, this would cause parts of output to go to chat, which may be desirable, but it might not in other cases
What we could possibly do is add an [adhoc] section to ansible.cfg and add an option load_callback_plugins=True/False
Though I’m also not wanting to make everything super configurable in ansible - that adds complexity to - that may be an alternative.
Hi Guys,
I have the same need to be able to log any actions made through ansible. I work in a company where we are used to manage our unix servers through ssh and custom scripts and i try to train my colleagues to use ansible instead. In the future, using ansible playbooks and roles is probably the best solution but for now, and considering the state of the servers already managed, it’s far easier to just replace custom scripts or launching simple commands through ssh by using ansible cli. But i’d like to be able to log every action made through ansible to have a king of journal of actions and ease the transition to a playbook based management.
I did the same modification as Adrien to /usr/bin/ansible, and it worked for my needs. I thinks the option in ansible.cfg is a good idea, not something that breaks existing code with a default of false but something really useful. It’s very confusing looking at callback examples and seeing on_runner_something and when you try to use them through /usr/bin/ansible, that does not work !!
Bruno
At this point I concur, an option (default off) is probably the best solution.
Let’s make it so, and if there’s a toggle in ansible.cfg I’ll merge it.
Thanks!
Here is the pull request on github GH 8911