I am using AWS ec2 module and I would like to log what userdata is sent to AWS with every command, but I don't want verbose output from all other useless tasks.
Is there any way I can enable verbosity of the ec2
module?
I agree with @techraf that there is no out of the box way to do this.
But Ansible is easily tuneable with plugins!
Drop this code as <playbook_dir>/callback_plugins/verbose_tasks.py
:
from ansible.plugins.callback import CallbackBase
import json
try:
from __main__ import display
except ImportError:
display = None
class CallbackModule(CallbackBase):
def v2_runner_on_any(self, result, ignore_errors=False):
if (result._task.action in ['file','stat']):
print '####### DEBUG ########'
print json.dumps(result._result,indent=4)
print '####### DEBUG ########'
v2_runner_on_ok = v2_runner_on_any
v2_runner_on_failed = v2_runner_on_any
You can tune what modules' results you want to print by changing ['file','stat']
list.
If you need only ec2
, replace it with ['ec2']
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With