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

**URL:** <https://forum.ansible.com/t/how-to-write-simple-messages-to-the-screen-in-a-module/16641>\
**Category:** Ansible Developer\
**Created:** [October 29, 2014, 9:20pm UTC](https://forum.ansible.com/t/how-to-write-simple-messages-to-the-screen-in-a-module/16641 "2014-10-29T21:20:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tennis\_Smith](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@Tennis\_Smith](https://forum.ansible.com/u/Tennis_Smith)\
**Post date:** [October 29, 2014, 9:20pm UTC](https://forum.ansible.com/t/how-to-write-simple-messages-to-the-screen-in-a-module/16641/1 "2014-10-29T21:20:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [October 29, 2014, 9:53pm UTC](https://forum.ansible.com/t/how-to-write-simple-messages-to-the-screen-in-a-module/16641/2 "2014-10-29T21:53:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 30, 2014, 5:25pm UTC](https://forum.ansible.com/t/how-to-write-simple-messages-to-the-screen-in-a-module/16641/3 "2014-10-30T17:25:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tennis\_Smith](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@Tennis\_Smith](https://forum.ansible.com/u/Tennis_Smith)\
**Post date:** [October 31, 2014, 3:04pm UTC](https://forum.ansible.com/t/how-to-write-simple-messages-to-the-screen-in-a-module/16641/4 "2014-10-31T15:04:53Z")

</div>

Thanks!  
-T
