Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to force ansible to use python3

I am running CentOS7. I have installed dnfand updated the default version on Centos to python3. I have added the ansible_python_interpreter=/bin/python3 on the inventory. Still when I run ansible -- version it still says python2.7. I have also done a yum erase ansible and then a dnfinstall ansible. Finally I uninstalled ansible and installed it via pip3 install ansible. Even after doing all this my version of python is still 2.7. What am I missing to get ansible to use python3 as it's default version?

like image 747
Coeurjoli Martinez Avatar asked Nov 23 '25 11:11

Coeurjoli Martinez


1 Answers

Follow the steps here which instruct on how to configure the python interpreter with the following variable:

ansible_python_interpreter=/usr/bin/python3

If you're using AWX you can create a group in your inventory which represents your python 3 hosts and set the variable at the group level. Or you can do it in global vars, or in the playbooks themselves.

There's some prerequisite work to do to enable python 3 in ansible. It's covered in the doc linked above.

like image 119
Colyn1337 Avatar answered Nov 25 '25 23:11

Colyn1337