Ansible_8
Use Python virtual environments for Ansible
To avoid version conflicts (Ansible, Python libs, collections) and its safe upgrades/testing without breaking system Python.
Intall Required Packages
# dnf install -y python3 python3-pip python3-virtualenv # optional suggestion pkges gcc python3-devel libffi-devel openssl-devel
Create virtual environment
# python3 -m venv ansible-env #This creates a folder ansible-env/ with isolated Python
If venv is missing # virtualenv ansible-env
Activate the environment
# source ansible-env/bin/activate
prompt will change like below
(ansible-env) user@host:~$
Install Ansible inside venv
$ pip install --upgrade pip
$ pip install ansible
$ ansible --version
$ ansible-galaxy collection install community.general
$ ansible-galaxy collection install ansible.posix
$ ansible-galaxy collection install community.vmware
$ ansible-playbook -i inventory.ini playbook.yml
Deactivate
$ ansible-playbook -i inventory.ini playbook.yml
eg
python3 -m venv /home/ralagarasan/uc-01
pip freeze > requirements.txt
pip install -r requirements.txt
Thursday, April 23, 2026
Ansible_8
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment