Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1.1 KB

File metadata and controls

44 lines (31 loc) · 1.1 KB

Install Ansible in a Virtual Env. (virtualenv)

Set Ansible in a sandboxed Python environment
(the preferred way to use Python/Ansible in production)

(See also Setup VirtualEnv)

Table of Contents

Setup the Host

virtualenv should be pre-installed as root:

sudo apt install python3
sudo apt install python3-pip
sudo -H pip3 install virtualenv

Activate the Virtual-Env

Set a folder-name (and location) for your virtual env', then initialize it:

export VENV_ANSIBLE=~/VENV_Ansible_2.9
virtualenv --system-site-packages "${VENV_ANSIBLE}"
source "${VENV_ANSIBLE}/bin/activate"

Install Ansible on the Virtual-Env

# Confirm you are in the context of the virtualenv
source "${VENV_ANSIBLE}/bin/activate"

# Choose a specific version of Ansible to install
pip3 install 'ansible==2.9.2'

# Confirm Ansible was installed OK
ansible --version