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

On Sat, May 2, 2020 at 7:41 PM alok ranjan <[email protected]> wrote:

> 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
>
> ---
> - hosts: unix_machine
>
>   vars:
>   # we should always use python3
>     ansible_python_interpreter: /usr/bin/python3
>   tasks:
>    - name: Load Storage System Vars
>      include_vars: 'properties/storage_system_properties.yml'
>
>    - name: Load Volume Vars
>      include_vars: 'properties/volume_properties.yml'
>
>    - name: Let'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=None, name=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 (True, True, "Created volume successfully.", {})
>         else:
>             return (True, False, "Volume already present", {})
>  except Exception as e:
>         return (False, False, "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
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1d80bd23-8ee8-4ce8-85a3-55f5bdcd96e5%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1d80bd23-8ee8-4ce8-85a3-55f5bdcd96e5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks,
Abhijeet Kasurde

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFwWkHqNgvgO65UqroAnE_FQB0Wp9bZqtYKeToAgQ9%2BJU%2BbV6Q%40mail.gmail.com.

Reply via email to