I wrote my own ansible module in python. It is working fine, however I would like to report some information during running task (task takes a long time). I know that after execution of task, stdout is written to console.
However, I would like to show some info during execution of task. Is it possible?
This is not possible out of the box right now (Ansible 2.7). There's proposal #92 for this.
But there's a way. I've talked about this concept during one of local meetups:
Core idea: wait for log stream inside ansible process on control host (using callback), ssh to remote host with backward tunnel, send logs to "localhost:9999", so they are sent back to control host via tunnel and displayed within ansible process.
Source code available here: https://github.com/berlic/wrikemeetup
Listening callback – callback_plugins/async_debug.py
Sending snippet (send_msg
) – module_utils/async_send.py
Demo module – library/slow_mod.py
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