module_stderr: Shared connection to IP closed

I have received the below error when I am executing the Ansible command. I am adding this error and the fix so it may help others.

The Ansible is installed on Centos machine and executing a command on remote Ubuntu machine and got below error message.


[root@localhost ~]# ansible -i ansible-proj/inventory all -m ping | FAILED! => {

    "changed": false, 

    "module_stderr": "Shared connection to closed.\r\n", 

    "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", 

    "msg": "MODULE FAILURE", 

    "rc": 0




The above error is coming because by default the Ubuntu 18 does not have python2. To overcome this issue install python2 on the remote machine or add python3 path in the Ansible inventory file.



To fix this issue am adding the python3 path in my inventory file (ansible-proj/inventory).


[root@localhost ~]# cat ansible-proj/inventory 

[all] ansible_python_interpreter=/usr/bin/python3


Here I have added python3 path in inventory file. Now execute the Ansible command to confirm it is working.


[root@localhost ~]# ansible -i ansible-proj/inventory all -m ping | SUCCESS => {

    "changed": false, 

    "ping": "pong"




Yes, this time the “ping” command worked successfully 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *