I have written custom ansible module. Module suppose to insert data in database via graphsql template.
While executing module via playbook, it does insert the data in database. however task is failing with below error,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 0
I am running this is verbose mode, module.exit_json is providing the output but in “Failed” state.
Need your help here.
Have you figure this out?
It looks like ansible can’t parse the return from your module.
Do you have any prints in your module dumping extra data out?
Ansible should also be giving you stdout and stderr lines with this message.
For example, I wrote a module that prints a message that looks like json (but is invalid) and then exists:
I had figured that out, and you rightly mentioned I had few print statement in the module, that was causing the problem.
Observation:
I am using python3.6.
Custom module had couple of print statement with f-string, and few print statement are normal (print statement used before python 3.6). Print statement with f-string was not causing any issue, only normal print statement were causing module to failed.
because ansible expects a single JSON document as a response on STDOUT
of the module .. if you do print statements .. you are probably
breaking that requirement, hence the error.