Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared connection to server failed (trying to run an Ansible playbook)

I am quite new to SSH servers and Ansible so this might be a dumb question.

Tried to run an Ansible playbook whilst accessing the server with a private key using the bash command below.

ansible-playbook dbserv.yml -i hosts --limit local-servers --private-key=(where I put the private key)

However, I am getting this error:

fatal: [xxx]: FAILED! => { "changed": false, "failed": true, "invocation": { "module_name": "setup" }, "module_stderr": "Shared connection to xxx closed.\r\n", "module_stdout": "/bin/sh: 1: /usr/bin/python2.7: not found\r\n", "msg": "MODULE FAILURE" }

I have Python installed on my computer so I do not understand why I am getting this error.

OS environment: Ubuntu 16.04.1

like image 814
sabrinazuraimi Avatar asked Dec 13 '16 05:12

sabrinazuraimi


1 Answers

The error message you get is:

/usr/bin/python2.7: not found

Ansible requires the target machine to have Python installed in order to work properly (see Managed node requirements).

The most likely reason is that your target is Ubuntu 16.04 which does not come with Python 2 installed. In this case you need to install it or try the experimental support for Python 3.

If Python 2.7 is installed in a different directory, you can add a host variable, for example in your inventory file (assuming the hostname is xxx as in your question`):

xxx ansible_python_interpreter=/path/to/python2.7

To run modules with Python 3 (experimental), set:

xxx ansible_python_interpreter=/usr/bin/python3

Note: Ansible by default looks for /usr/bin/python, so it's likely that your playbook, inventory file, or ansible.cfg already contain settings for /usr/bin/python2.7 which does not exist on the target machine.

like image 75
techraf Avatar answered Oct 26 '22 09:10

techraf