# ansible 1.9.4 task reported failed from running custom python module

**URL:** <https://forum.ansible.com/t/ansible-1-9-4-task-reported-failed-from-running-custom-python-module/20668>\
**Category:** Ansible Project\
**Created:** [February 24, 2016, 6:35pm UTC](https://forum.ansible.com/t/ansible-1-9-4-task-reported-failed-from-running-custom-python-module/20668 "2016-02-24T18:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hongjun\_Ma](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@Hongjun\_Ma](https://forum.ansible.com/u/Hongjun_Ma)\
**Post date:** [February 24, 2016, 6:35pm UTC](https://forum.ansible.com/t/ansible-1-9-4-task-reported-failed-from-running-custom-python-module/20668/1 "2016-02-24T18:35:25Z")

</div>

Hello, my own python module returned the following failure when running from ansible.

{“msg”: “Created profile”, “changed”: true, “ansible\_facts”: {“serial\_number”: … “created”: true}}

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/hongjun/ov\_site.retry

demo-web1 : ok=0 changed=0 unreachable=0 failed=1

I trimmed ansible\_facts msg for readability. I don’t understand where ansible is complaining about. My python module successfully finished the task at the end system. If I keep Ansible temp python file and trace directly from Pycharm, I can see the call is returned successfully from my module to ansible exit\_json function with all information passed correctly.

def exit\_json(self, \*\*kwargs):  
‘’’ return from the module, without error ‘’’  
self.add\_path\_info(kwargs)  
if not ‘changed’ in kwargs:  
kwargs[‘changed’] = False  
self.do\_cleanup\_files()  
print self.jsonify(kwargs)  
sys.exit(0)

My charm returned with exit code 0  
Process finished with exit code 0

The playbook has a simple task calling my module ov\_server, inventory only has one host defined. Python is 2.7.11

- name: Create Server Profiles  
ov\_server:  
oneview\_host: “{{ oneview }}”  
username: “{{ ov\_username }}”  
password: “{{ ov\_password }}”  
server\_template: “{{ ov\_template }}”  
name: “{{ inventory\_hostname }}”  
delegate\_to: localhost

---

<div class="post-metadata">

**Author:** ![Hongjun\_Ma](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@Hongjun\_Ma](https://forum.ansible.com/u/Hongjun_Ma)\
**Post date:** [February 24, 2016, 6:47pm UTC](https://forum.ansible.com/t/ansible-1-9-4-task-reported-failed-from-running-custom-python-module/20668/2 "2016-02-24T18:47:34Z")

</div>

i figured out the issue. I added some print statements during python module troubleshooting and looks Ansible didn’t like that. I commented out the print statements and ansible is happy now.
