Ansible and Python3

Posted by

I have reinstall my servers recently an migrated to Ubuntu 18.04, Bionic Beaver and on this version, Python2 is still available but not installed by default. I do the deployments with Ansible from my Macbook who is still using Python2, so I was getting the following error:

TASK [Gathering Facts] *
fatal: [aphrodite]: FAILED! => {“changed”: false, “module_stderr”: “Shared connection to myserver closed.\r\n”, “module_stdout”: “/bin/sh: 1: /usr/bin/python: not found\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 127}

To fix this error, create the file group_vars/all in your project and add:

ansible_python_interpreter: /usr/bin/python3

Now Ansible will use Python3 to deploy your playbook(s)

Leave a Reply

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