Reputation: 1319
I want to use python 3.6 with Ansible on the managed nodes (controlling node can use whatever, I guess).
On its official doc, it says to enable python 3.6 on managed nodes, I have to set the ansible_python_interpreter
configuration option to /usr/bin/python3
. This option is an inventory option
. I know it is possible to set this inventory variable even with dynamic inventory, but I just don't want that much complexity going into setting a variable.
So I did not set this option, instead I:
ec2_module
to automatically provision an aws ec2 ubuntu18.04 (which comes with python 3.6 at /usr/bin/python3
) (I could also use raw
module to install it if it's not present)raw
module to create a symlink from /usr/bin/python
to /usr/bin/python3
I tried it and it seems as long as the /usr/bin/python
is set to an acceptable version of python (>= 2.7
or >= 3.6
) then it should work...
Question: So what's the point of setting the ansible_python_interpreter configuration option to /usr/bin/python3
?
Upvotes: 0
Views: 8418
Reputation: 312243
Question: So what's the point of setting the ansible_python_interpreter configuration option to /usr/bin/python3?
By default, Ansible will always use /usr/bin/python
on the remote system. You set ansible_python_interpreter
to provide a path to something that isn't /usr/bin/python
if you want it to use that instead. Sure, you can create a symlink instead, but:
/usr/bin/python
already exists and is Python 2 and is required by system tools. Replacing it will break things./usr/bin/python
to /usr/bin/python3
you have potentially broken anything that expects /usr/bin/python
to be Python 2. That might not bite you now but it might surprise you in the future.Upvotes: 3