ANSIBLE - Venv - Use /usr/bin/ansible

Hi experts,

In order to manage network devices, I’m currently setting up an environment with ansible inside a python venv on a linux Alma 8 platform.

Below, the steps I used to install the components :

# Venv creation
[MyUser@MyAnsibleVm ~]$python3 -m venv ansible4.10
[MyUser@MyAnsibleVm ~]$source ansible4.10/bin/activate

# pip installation / upgrade
(ansible4.10) [MyUser@MyAnsibleVm ~]$python3 -m ensurepip --default-pip
(ansible4.10) [MyUser@MyAnsibleVm ~]$python3 -m pip install --upgrade pip

# Ansible installation
(ansible4.10) [MyUser@MyAnsibleVm ~]$python3 -m pip install ansible

At the end we have ansible installed correctly. All the steps seems to be good.
# List packages
(ansible4.10) [MyUser@MyAnsibleVm ~]$ python3 -m pip list
Package Version


ansible 4.10.0
ansible-core 2.11.12
cffi 1.15.1
cryptography 38.0.3
Jinja2 3.0.3

Unfortunately, if I check the ansible version inside my venv, I still have my old global ansible version, rather than the new venv version :

(ansible4.10) [MyUser@MyAnsibleVm ~]$ ansible --version
ansible 2.9.10
config file = /etc/ansible/ansible.cfg
configured module search path = [‘/home/MyUser/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible

python version = 3.6.8 (default, May 24 2021, 08:40:28) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

Any ideas to help ?

Thank you

Ju

Finally, the problem was related to security restrictions on the partition where my venv was located.

It works perfectly on another mounting point.

Ju