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.
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
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.