Hi @Jbor,

Thanks for your reply.

Even after setting `ansible_python_interpreter` var at different level, i 
cannot see in the verbose output of playbook command that python3 is 
getting used on the managed nodes. 

Can you please check the playbook output here https://pastebin.com/zEx6qTXk 
if i missing something? 

Thanks,

On Friday, June 30, 2023 at 4:08:52 AM UTC+5:30 [email protected] wrote:

> The Ansible engine side only runs on the python that it was installed in, 
> which in your case is 2.7.5. The ansible_python_interpreter controls what 
> Python is used to run the modules on the remote target. You can see what 
> Python was invoked for that scenario by running Ansible with -vvv. If you 
> want to run the Ansible engine with your Python 3.6, the simplest way is to 
> install Ansible with that python version.
>
> On Friday, June 30, 2023 at 12:30:42 AM UTC+10 cool prat wrote:
>
>> Hi Team,
>>
>> I want to use python3 for using k8s module (`kubernetes.core.k8s_info`) 
>> on the ansible controller node which RHEL 7.
>>
>> Python2 is already installed. I have installed python3.
>>
>> I am trying to use python3 by setting ansible_python_interpreter var but 
>> its still showing that its using python version 2 in the command like 
>> ansible --version. 
>>
>>
>> `ansible_python_interpreter` is already set at multiple level and even 
>> after using all the options together, its still not picking up python3 and 
>> giving same error.
>>
>>
>> Have set the var ansible_python_interpreter at i) inventory, ii) 
>> playbook, iii) /home/sac/ansible.cfg and iv) with -e option as well in 
>> ansible-playbook` 
>> command.
>>
>> i) Added in inventory -
>> # ans.ini #localhost ansible_connection=local localhost 
>> ansible_python_interpreter=/opt/rh/rh-python36/root/usr/bin/python3.6 
>>
>> ii) added in playbook
>> - hosts: localhost connection: local gather_facts: no vars: 
>> ansible_python_interpreter: /opt/rh/rh-python36/root/usr/bin/python3.6 
>> tasks: . . 
>>
>> iii) ansible.cfg
>> # cat ansible.cfg [defaults] ANSIBLE_PYTHON_INTERPRETER = 
>> /opt/rh/rh-python36/root/usr/bin/python3.6 interpreter_python = 
>> /opt/rh/rh-python36/root/usr/bin/python3.6 ansible_python_interpreter = 
>> /opt/rh/rh-python36/root/usr/bin/python3.6 
>>
>> iv) Added as -e in ansible-playbook command,
>> ansible-playbook -i ans.ini ans.yml -e 
>> 'ansible_python_interpreter=/opt/rh/rh-python36/root/usr/bin/python3.6'
>>
>> Below showing python 2.7.5
>>
>> # ansible --version ansible 2.9.27 config file = /etc/ansible/ansible.cfg 
>> configured module search path = [u'/home/sac/.ansible/plugins/modules', 
>> u'/usr/share/ansible/plugins/modules'] ansible python module location = 
>> /usr/lib/python2.7/site-packages/ansible executable location = /bin/ansible 
>> python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 
>> (Red Hat 4.8.5-44)]
>>
>> How can i make changes so that ansible will start using python 3
>>
>> Thanks,
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d65bfd70-4319-4d21-844a-30cd71d16daan%40googlegroups.com.

Reply via email to