Auto-set ansible_python_interpreter when in venv

Ansible doesn't seem to correctly configure python interpreter
while running in a virtual environment and defaults to the system
wide installation. This can lead to missing dependencies and/or
version mismatch issues. This change adds automatic configuration
of ansible_python_interpreter value based on VENV environment
variable for each of the roles provided by bifrost.

Change-Id: I0bc6a0ee7519bca0fe81eb74349427681269a740
This commit is contained in:
Jacob Anders
2020-07-22 13:00:23 +10:00
parent f29bbf2d1d
commit 3c5377ce92
16 changed files with 60 additions and 1 deletions

View File

@@ -2,3 +2,8 @@
node_ssh_pause: 10
wait_timeout: 900
multinode_testing: false
# Ensure that Ansible is using python interpreter and dependencies inside the bifrost virtual environment
enable_venv: true
bifrost_venv_dir: "{{ lookup('env', 'VENV') or '/opt/stack/bifrost' }}"
ansible_python_interpreter: "{{ bifrost_venv_dir + '/bin/python3' if enable_venv | bool else '/usr/bin/python3' }}"