Thanks for the response Abhijeet. I forgot to mention this. I have already done the following 1. export ANSIBLE_DEBUG=1 on cmd prompt 2.ansible-playbook playbook/nimble_volume_playbook.yml -i hosts -vvvvv 3. Please not that i have logged in as root user.
I am posting the log snippet for reference. I am not able to see or find any meaningful errror. Is it something to do with SSH.It just says failed. (marked in red) but has no reason as to why it failed.or may be i am missing something **************************************LOG********************* ow_level_execute_command(): starting 2020-05-02 21:37:11,810 p=32124 u=root n=ansible | 32124 1588435631.80998: _low_level_execute_command(): executing: /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1588435628.8612363-32124-188228841420034/ > /dev/null 2>&1 && sleep 0' 2020-05-02 21:37:11,810 p=32124 u=root n=ansible | <10.18.180.239> ESTABLISH SSH CONNECTION FOR USER: None 2020-05-02 21:37:11,811 p=32124 u=root n=ansible | <10.18.180.239> SSH: ansible.cfg set ssh_args: (-C)(-o)(ControlMaster=auto)(-o)(ControlPersist=60s) 2020-05-02 21:37:11,811 p=32124 u=root n=ansible | <10.18.180.239> SSH: ANSIBLE_HOST_KEY_CHECKING/host_key_checking disabled: (-o)(StrictHostKeyChecking=no) 2020-05-02 21:37:11,811 p=32124 u=root n=ansible | <10.18.180.239> SSH: ANSIBLE_TIMEOUT/timeout set: (-o)(ConnectTimeout=20) 2020-05-02 21:37:11,812 p=32124 u=root n=ansible | <10.18.180.239> SSH: PlayContext set ssh_common_args: () 2020-05-02 21:37:11,812 p=32124 u=root n=ansible | <10.18.180.239> SSH: PlayContext set ssh_extra_args: () 2020-05-02 21:37:11,813 p=32124 u=root n=ansible | <10.18.180.239> SSH: found only ControlPersist; added ControlPath: (-o)(ControlPath=/root/.ansible/cp/2f7fdd7fde) 2020-05-02 21:37:11,813 p=32124 u=root n=ansible | <10.18.180.239> SSH: EXEC sshpass -d10 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o ConnectTimeout=20 -o ControlPath=/root/.ansible/cp/2f7fdd7fde 10.18.180.239 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1588435628.8612363-32124-188228841420034/ > /dev/null 2>&1 && sleep 0'"'"'' 2020-05-02 21:37:11,824 p=32124 u=root n=ansible | 32124 1588435631.82391: stderr chunk (state=2): >>>OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018 debug1: Reading configuration data /etc/ssh/ssh_config debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0 debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config debug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-] debug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1] debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for * debug2: resolve_canonicalize: hostname 10.18.180.239 is address <<< 2020-05-02 21:37:11,825 p=32124 u=root n=ansible | 32124 1588435631.82500: stderr chunk (state=3): >>>debug1: auto-mux: Trying existing master debug2: fd 4 setting O_NONBLOCK debug2: mux_client_hello_exchange: master version 4 debug3: mux_client_forwards: request forwardings: 0 local, 0 remote debug3: mux_client_request_session: entering debug3: mux_client_request_alive: entering debug3: mux_client_request_alive: done pid = 30870 debug3: mux_client_request_session: session request sent <<< 2020-05-02 21:37:11,892 p=32124 u=root n=ansible | 32124 1588435631.89225: stderr chunk (state=3): >>>debug3: mux_client_read_packet: read header failed: Broken pipe debug2: Received exit status from master 0 <<< 2020-05-02 21:37:11,893 p=32124 u=root n=ansible | 32124 1588435631.89299: stderr chunk (state=3): >>><<< 2020-05-02 21:37:11,893 p=32124 u=root n=ansible | 32124 1588435631.89329: stdout chunk (state=3): >>><<< 2020-05-02 21:37:11,893 p=32124 u=root n=ansible | <10.18.180.239> (0, b'', b'OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 10.18.180.239 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 30870\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n') 2020-05-02 21:37:11,894 p=32124 u=root n=ansible | 32124 1588435631.89418: _low_level_execute_command() done: rc=0, stdout=, stderr=OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018 debug1: Reading configuration data /etc/ssh/ssh_config debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0 debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config debug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-] debug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1] debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for * debug2: resolve_canonicalize: hostname 10.18.180.239 is address debug1: auto-mux: Trying existing master debug2: fd 4 setting O_NONBLOCK debug2: mux_client_hello_exchange: master version 4 debug3: mux_client_forwards: request forwardings: 0 local, 0 remote debug3: mux_client_request_session: entering debug3: mux_client_request_alive: entering debug3: mux_client_request_alive: done pid = 30870 debug3: mux_client_request_session: session request sent debug3: mux_client_read_packet: read header failed: Broken pipe debug2: Received exit status from master 0 2020-05-02 21:37:11,894 p=32124 u=root n=ansible | 32124 1588435631.89459: handler run complete 2020-05-02 21:37:11,895 p=32124 u=root n=ansible | 32124 1588435631.89509: attempt loop complete, returning result 2020-05-02 21:37:11,895 p=32124 u=root n=ansible | 32124 1588435631.89546: _execute() done 2020-05-02 21:37:11,895 p=32124 u=root n=ansible | 32124 1588435631.89569: dumping result to json 2020-05-02 21:37:11,896 p=32124 u=root n=ansible | 32124 1588435631.89599: done dumping result, returning 2020-05-02 21:37:11,896 p=32124 u=root n=ansible | 32124 1588435631.89640: done running TaskExecutor() for 10.18.180.239/TASK: Let's Create Volume "ansible-volume3" [00505696-cba7-9fef-6d87-00000000000a] 2020-05-02 21:37:11,897 p=32124 u=root n=ansible | 32124 1588435631.89695: sending task result for task 00505696-cba7-9fef-6d87-00000000000a 2020-05-02 21:37:11,897 p=32124 u=root n=ansible | 32124 1588435631.89788: done sending task result for task 00505696-cba7-9fef-6d87-00000000000a 2020-05-02 21:37:11,899 p=32124 u=root n=ansible | 32124 1588435631.89937: WORKER PROCESS EXITING *2020-05-02 21:37:11,900 p=31826 u=root n=ansible | 31826 1588435631.90026: marking 10.18.180.239 as failed* *2020-05-02 21:37:11,900 p=31826 u=root n=ansible | 31826 1588435631.90069: marking host 10.18.180.239 failed, current state: HOST STATE: block=2, task=3, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False* 2020-05-02 21:37:11,901 p=31826 u=root n=ansible | 31826 1588435631.90100: ^ failed state is now: HOST STATE: block=2, task=3, rescue=0, always=0, run_state=ITERATING_COMPLETE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False 2020-05-02 21:37:11,901 p=31826 u=root n=ansible | 31826 1588435631.90125: getting the next task for host 10.18.180.239 2020-05-02 21:37:11,901 p=31826 u=root n=ansible | 31826 1588435631.90146: host 10.18.180.239 is done iterating, returning 2020-05-02 21:37:11,902 p=31826 u=root n=ansible | *fatal: [10.18.180.239]: FAILED! => {* "changed": false, "module_stderr": "OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS 11 Sep 2018\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 10.18.180.239 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 4 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 30870\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 10.18.180.239 closed.\r\n", "module_stdout": "https://10.18.171.96:5392/v1/volumes\r\n{'data': {'name': 'ansible-volume3', 'size': 80}}\r\n\r\n{\"return_status\": true, \"changed\": true, \"msg\": \"Created volume successfully.\", \"invocation\": {\"module_args\": {\"hpe_nimble_array_ip\": \"10.18.171.96\", \"hpe_nimble_array_username\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"hpe_nimble_array_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"hpe_nimble_array_protocol\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"volume_name\": \"ansible-volume3\", \"state\": \"create\", \"size\": 80}}}\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 0 } 2020-05-02 21:37:11,902 p=31826 u=root n=ansible | 31826 1588435631.90260: no more pending results, returning what we have 2020-05-02 21:37:11,902 p=31826 u=root n=ansible | 31826 1588435631.90287: results queue empty 2020-05-02 21:37:11,903 p=31826 u=root n=ansible | 31826 1588435631.90307: checking for any_errors_fatal 2020-05-02 21:37:11,903 p=31826 u=root n=ansible | 31826 1588435631.90339: done checking for any_errors_fatal 2020-05-02 21:37:11,903 p=31826 u=root n=ansible | 31826 1588435631.90369: checking for max_fail_percentage 2020-05-02 21:37:11,904 p=31826 u=root n=ansible | 31826 1588435631.90403: done checking for max_fail_percentage 2020-05-02 21:37:11,904 p=31826 u=root n=ansible | 31826 1588435631.90431: checking to see if all hosts have failed and the running result is not ok 2020-05-02 21:37:11,904 p=31826 u=root n=ansible | 31826 1588435631.90461: done checking to see if all hosts have failed 2020-05-02 21:37:11,905 p=31826 u=root n=ansible | 31826 1588435631.90491: getting the remaining hosts for this loop 2020-05-02 21:37:11,905 p=31826 u=root n=ansible | 31826 1588435631.90522: done getting the remaining hosts for this loop 2020-05-02 21:37:11,905 p=31826 u=root n=ansible | 31826 1588435631.90566: building list of next tasks for hosts 2020-05-02 21:37:11,906 p=31826 u=root n=ansible | 31826 1588435631.90594: getting the next task for host 10.18.180.239 2020-05-02 21:37:11,906 p=31826 u=root n=ansible | 31826 1588435631.90621: host 10.18.180.239 is done iterating, returning 2020-05-02 21:37:11,906 p=31826 u=root n=ansible | 31826 1588435631.90648: done building task lists 2020-05-02 21:37:11,906 p=31826 u=root n=ansible | 31826 1588435631.90681: counting tasks in each state of execution 2020-05-02 21:37:11,907 p=31826 u=root n=ansible | 31826 1588435631.90710: done counting tasks in each state of execution: num_setups: 0 num_tasks: 0 num_rescue: 0 num_always: 0 2020-05-02 21:37:11,907 p=31826 u=root n=ansible | 31826 1588435631.90740: all hosts are done, so returning None's for all hosts 2020-05-02 21:37:11,907 p=31826 u=root n=ansible | 31826 1588435631.90771: done queuing things up, now waiting for results queue to drain 2020-05-02 21:37:11,908 p=31826 u=root n=ansible | 31826 1588435631.90802: results queue empty 2020-05-02 21:37:11,908 p=31826 u=root n=ansible | 31826 1588435631.90829: checking for any_errors_fatal 2020-05-02 21:37:11,908 p=31826 u=root n=ansible | 31826 1588435631.90858: done checking for any_errors_fatal 2020-05-02 21:37:11,909 p=31826 u=root n=ansible | 31826 1588435631.90888: checking for max_fail_percentage 2020-05-02 21:37:11,909 p=31826 u=root n=ansible | 31826 1588435631.90916: done checking for max_fail_percentage 2020-05-02 21:37:11,909 p=31826 u=root n=ansible | 31826 1588435631.90941: checking to see if all hosts have failed and the running result is not ok 2020-05-02 21:37:11,909 p=31826 u=root n=ansible | 31826 1588435631.90965: done checking to see if all hosts have failed 2020-05-02 21:37:11,910 p=31826 u=root n=ansible | 31826 1588435631.90993: getting the next task for host 10.18.180.239 2020-05-02 21:37:11,910 p=31826 u=root n=ansible | 31826 1588435631.91017: host 10.18.180.239 is done iterating, returning 2020-05-02 21:37:11,910 p=31826 u=root n=ansible | 31826 1588435631.91043: running handlers 2020-05-02 21:37:11,912 p=31826 u=root n=ansible | PLAY RECAP *************************************************************************** 2020-05-02 21:37:11,912 p=31826 u=root n=ansible | 10.18.180.239 : ok=3 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 2020-05-02 21:37:11,912 p=31826 u=root n=ansible | 31826 1588435631.91258: RUNNING CLEANUP On Saturday, 2 May 2020 20:14:27 UTC+5:30, Abhijeet Kasurde wrote: > > 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] > <javascript:>> 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] <javascript:>. >> 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/bc2d3803-bdfd-4a2c-acd3-3b4b90f84dc9%40googlegroups.com.
