How To Write Simple Messages To The Screen In A Module?

Hi,

I’m writing a small module in Python. What is the preferred way to write informational (i.e. non-error) messages to the user’s screen while the module runs? The methods “fail_json” and “exit_json” both cause the module to exit.

TIA,
-T

Generally speaking, there is no such way. A module should only print results at the end using exit_json or fail_json.

What are you trying to accomplish?

yeah returning things like a “msg” attribute in the module would be sufficient to provide some info when it returns, but you can’t do anything along the way.

And you’d only see the value of “msg” in verbose mode or if you did:

  • module: foo=1 bar=2

register: foo_result

  • debug: var=foo_result.msg

Thanks!
-T