Skip to content

Instantly share code, notes, and snippets.

@aspen-roller
Last active December 7, 2020 20:30
Show Gist options
  • Save aspen-roller/db6c42648bfa71bff948ebbb2e809e73 to your computer and use it in GitHub Desktop.
Save aspen-roller/db6c42648bfa71bff948ebbb2e809e73 to your computer and use it in GitHub Desktop.
python venv for ansible testing #ansible #python
# colorize molecule test outputs
export PY_COLORS=1
# encrypted variables
export ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible/.vault_password
scp zscaler.crt user@remote:/tmp
ssh user@remote
sudo mv /tmp/zscaler.crt /usr/local/share/ca-certificates
sudo update-ca-certificates
# run setup-zscaler.sh first
# set the vault password (sadevopstovault's password)
mkdir ~/.ansible
echo 'xxx' > ~/.ansible/.vault_password
chmod 600 ~/.ansible/.vault_password
sudo apt-get update
# Ubuntu 20.04
sudo apt-get install python3-venv
# Ubuntu 18.04
sudo apt-get install python3-pip python3-venv
cd
mkdir python-env
cd python-env
# make an environment for ansible-2.9.x
python3 -m venv ansible-2.9
# switch to the new environment
source ansible-2.9/bin/activate
pip install --upgrade pip
pip config --site set global.cert /usr/local/share/ca-certificates/zscaler.crt
pip install --upgrade setuptools wheel
# if the upgrade fails add the following
pip config --site set global.trusted-host 'pypi.org files.pythonhosted.org'
# install ansible and related tools
pip --timeout 1000 install ansible[azure]==2.9.15 ansible-lint hvac[parser] jmespath molecule[docker] yamllint
# exit the environment
deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment