# Shell module failed

**URL:** <https://forum.ansible.com/t/shell-module-failed/17901>\
**Category:** Ansible Project\
**Created:** [April 3, 2015, 12:10pm UTC](https://forum.ansible.com/t/shell-module-failed/17901 "2015-04-03T12:10:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sluge1\_Slug2](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sluge1\_Slug2](https://forum.ansible.com/u/Sluge1_Slug2)\
**Post date:** [April 3, 2015, 12:10pm UTC](https://forum.ansible.com/t/shell-module-failed/17901/1 "2015-04-03T12:10:22Z")

</div>

Hello, ansible users,

I have created a simple module for ansible:

#!/bin/sh

hostname

exit 0

but this module failed to execute:

# ansible 192.168.1.10 -m test.sh -M /ans\_mod

192.168.1.10 | FAILED \>\> {  
“failed”: true,  
“msg”: “[mngclient.prj.comp.com](http://mngclient.prj.comp.com)\r\n”,  
“parsed”: false  
}

How to make ansible to execute this module successfully?

---

<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:** [April 3, 2015, 12:49pm UTC](https://forum.ansible.com/t/shell-module-failed/17901/2 "2015-04-03T12:49:29Z")

</div>

Modules must return JSON data not just a single string.

---

<div class="post-metadata">

**Author:** ![Sluge1\_Slug2](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sluge1\_Slug2](https://forum.ansible.com/u/Sluge1_Slug2)\
**Post date:** [April 3, 2015, 1:26pm UTC](https://forum.ansible.com/t/shell-module-failed/17901/3 "2015-04-03T13:26:02Z")

</div>

Matt, thatks a lot for the info

How to convert console output to the JSON data?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 3, 2015, 2:00pm UTC](https://forum.ansible.com/t/shell-module-failed/17901/4 "2015-04-03T14:00:19Z")

</div>

echo '{"hostname": "' $(hostname) '"}'
