[SOS] Error with self-developed shell module

46 views
Skip to first unread message

edison wang

unread,
Jan 12, 2016, 8:29:19 AM1/12/16
to Ansible Project
hi,

  I wrote a simple shell script and made it as Ansible module with putting it under Library Path. I ran the module and got the failure message. However, I can tell from the output message that the shell module has been run actually. So I don't understand why Ansible returns such failure message.

Below has the detail, the OS type of target system is AIX

root@b1a52ef5f33f:/usr/share/my_modules# ansible aix -m getos
9.123.195.164 | FAILED! => {
    "changed": false,
    "failed": true,
    "module_stderr": "",
    "module_stdout": "AIX lpar1 1 7 00CB4D6E4C00\r\n",
    "msg": "MODULE FAILURE",
    "parsed": false
}


root@b1a52ef5f33f:/usr/share/my_modules# cat getos
#!/bin/sh

uname -a

Meanwhile, I used the test-module utility to test my shell module and see error with "ValueError: No JSON object could be decoded". So I assume that is the root cause maybe. 

root@b1a52ef5f33f:/ansible# hacking/test-module -m /usr/share/my_modules/getos
* including generated source, if any, saving to: /root/.ansible_module_generated
* this may offset any line numbers in tracebacks/debuggers!
***********************************
RAW OUTPUT
Linux b1a52ef5f33f 4.1.13-boot2docker #1 SMP Fri Nov 20 19:05:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


***********************************
INVALID OUTPUT FORMAT
Linux b1a52ef5f33f 4.1.13-boot2docker #1 SMP Fri Nov 20 19:05:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Traceback (most recent call last):
  File "hacking/test-module", line 167, in runtest
    results = json.loads(out)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded


I'm not sure whether i am right. But even so, i still have no idea how to solve my problem.

Would you please help me out? Thanks very much

Brian Coca

unread,
Jan 12, 2016, 9:56:27 AM1/12/16
to Ansible Project
"AIX lpar1 1 7 00CB4D6E4C00\r\n",

^ that is not JSON, modules MUST return JSON to Ansible.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages