Skip to content

Instantly share code, notes, and snippets.

@isweluiz
Last active October 16, 2022 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isweluiz/0a78545264b1de672177347c74748fd3 to your computer and use it in GitHub Desktop.
Save isweluiz/0a78545264b1de672177347c74748fd3 to your computer and use it in GitHub Desktop.

How to switch your ansible version in the same env?

Ansible is just a python package,if you have virtualenv installed on your host it is just a matter of creating a new venv for each ansible version you want, and then pip install it.

First, verify the installed Python version and path. Create a virtual environment using the python3 -m venv <environment-name> command. You can give any name to your Python virtual environment. I want to try the Ansible 2.10 version, so I named it in a way to identify the directory easily:

$mkdir ~/venvs/
$cd !$
$python3 -m venv ansible2.10

Activate a Python virtual environment

$source ansible2.10/bin/activate
$pip install "ansible==2.10"  --user
$ansible --version
ansible 2.10.17

Deactivate a Python virtual environment

$deactivate  

More details:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment