ansible 1.9.4 task reported failed from running custom python module

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

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.