7

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?

U880D
  • 8,601
  • 6
  • 24
  • 40
Docker fun
  • 113
  • 1
  • 7

1 Answers1

10

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:

out of band logging

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

Modules:

Listening callback – callback_plugins/async_debug.py
Sending snippet (send_msg) – module_utils/async_send.py
Demo module – library/slow_mod.py

U880D
  • 8,601
  • 6
  • 24
  • 40
Konstantin Suvorov
  • 65,183
  • 9
  • 162
  • 193