MODULE FAILURE\nSee stdout/stderr for the exact error on ansible version 2.9. python is 3.6

6,316 views
Skip to first unread message

alok ranjan

unread,
May 2, 2020, 10:11:17 AM5/2/20
to Ansible Project
Hi,

I am trying to develop my own custom ansible module . my env machine is centos and python version is 3.6. ansible version is 2.9.6


here is the playbook

---
hostsunix_machine

  vars:
  # we should always use python3
    ansible_python_interpreter/usr/bin/python3
  tasks:
   - nameLoad Storage System Vars
     include_vars'properties/storage_system_properties.yml'

   - nameLoad Volume Vars
     include_vars'properties/volume_properties.yml'

   - nameLet's Create Volume "{{ volume_name }}"
     volume:
        array_ip="{{ array_ip }}"
        array_username="{{ array_username }}"
        array_password="{{ array_password }}"
        array_protocol="{{ array_protocol }}"
        volume_name="{{ volume_name }}"
        state=create
        size="{{ size }}"


everytime i run the plabook, the volume successfully gets created on array but then at the end it says task failed with below error

*********************************************************************** "module_stdout": "https://10.18.171.96:5392/v1/volumes\r\n{'data': {'name': 'ansible-volume1', 'size': 80}}\r\n\r\n{\"return_status\": true, \"changed\": false, \"msg\": \"Created volume successfully.\", \"invocation\": {\"module_args\": {\"array_ip\": \"1.x.x.x\", \"array_username\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"array_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"array_protocol\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"volume_name\": \"ansible-volume1\", \"state\": \"create\", \"size\": 80}}}\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", >>>>>>>>>>>>>>>>>>>>>>>>>> ERROR <<<<<<<<<<<<<<<<<<<<<<<< "rc": 0 } PLAY RECAP *************************************************************************** 10.18.180.239 : ok=3 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0


There is nothing more on the stdout or stderr. The custom module just makes a rest api call to create a volume on array. I am not sure why i am getting the task as failed. If you see the rc code is also
0. Please help


my custom module code is in python :



def create_volume(
        client_obj,
        hpe_nimble_array_protocol,
        volume_name,
        size=10):

    if volume_name is None:
        return (
            False,
            False,
            "Volume creation failed. Volume name is null",
            {})
    try:
        if not client_obj.volumes.get(id=Nonename=volume_name):
            resp = client_obj.volumes.create(volume_name, size=size)
            assert resp is not None
            # return (True, False, "Created volume %s successfully." % volume_name, {})
            return (TrueTrue"Created volume successfully.", {})
        else:
            return (TrueFalse"Volume already present", {})
 except Exception as e:
        return (FalseFalse"Volume creation failed | %s" % e, {})






    # States
    if module.params["state"] == "create":
        return_status, changed, msg, issue_attr_dict = create_volume(
            client_obj, hpe_nimble_array_protocol, volume_name, size)
    if return_status:
        if issue_attr_dict:
            module.exit_json(changed=changed, msg=msg, issue=issue_attr_dict)
        else:
            module.exit_json(return_status=return_status, changed=changed, msg=msg)
Thanks, Alok

Abhijeet Kasurde

unread,
May 2, 2020, 10:44:27 AM5/2/20
to ansible...@googlegroups.com
Could you please run ansible-playbook command with `-vvvv`? Also, you can go through this debugging help - https://docs.ansible.com/ansible/latest/dev_guide/debugging.html

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1d80bd23-8ee8-4ce8-85a3-55f5bdcd96e5%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde
Reply all
Reply to author
Forward
Message has been deleted
0 new messages