kolla-ansible/doc/source/user/virtual-environments.rst
Mark Goddard 6c037790f2 Refactor MariaDB and RabbitMQ restart procedure
Ansible 2.14.3 introduced a change that broke the method used for
restarting MariaDB and RabbitMQ serially [1][2]. In
I57425680a4cdbf0daeb9b2cc35920f1b933aa4a8 we limited to 2.14.2 to work
around this. Ansible upstream claim this behaviour was unintentional,
and will not fix it.

This change moves to a different approach where we use separate plays
with a 'serial' keyword to execute the restart.

This change also removes the restriction on the maximum supported
version of 2.14.2 on ansible-core - any 2.14 release is now supported.

[1] 65366f663d
[2] https://github.com/ansible/ansible/issues/80848

Depends-On: https://review.opendev.org/c/openstack/kolla/+/884208

Change-Id: I5a12670d07077d24047aaff57ce8d33ccf7156ff
2023-06-17 21:02:49 +00:00

2.6 KiB

Virtual Environments

Python virtual environments provide a mechanism for isolating python packages from the system site packages and other virtual environments. Kolla-ansible largely avoids this problem by deploying services in Docker containers, however some python dependencies must be installed both on the Ansible control host and the target hosts.

Kolla Ansible supports the default Python 3 versions provided by the supported Operating Systems <user/support-matrix>. For more information see tested runtimes.

Ansible Control Host

The kolla-ansible python package and its dependencies may be installed in a python virtual environment on the Ansible control host. For example:

python3 -m venv /path/to/venv
source /path/to/venv/bin/activate
pip install -U pip
pip install kolla-ansible
pip install 'ansible>=6,<8'
deactivate

To use the virtual environment, it should first be activated:

source /path/to/venv/bin/activate
(venv) kolla-ansible --help

The virtual environment can be deactivated when necessary:

(venv) deactivate

Note that the use of a virtual environment on the Ansible control host does not imply that a virtual environment will be used for execution of Ansible modules on the target hosts.

Target Hosts

Ansible supports remote execution of modules in a python virtual environment via the ansible_python_interpreter variable. This may be configured to be the path to a python interpreter installed in a virtual environment. For example:

ansible_python_interpreter: /path/to/venv/bin/python

Note that ansible_python_interpreter cannot be templated.

Kolla-ansible provides support for creating a python virtual environment on the target hosts as part of the bootstrap-servers command. The path to the virtualenv is configured via the virtualenv variable, and access to site-packages is controlled via virtualenv_site_packages. Typically we will need to enable use of system site-packages from within this virtualenv, to support the use of modules such as yum, apt, and selinux, which are not available on PyPI.

When executing kolla-ansible commands other than bootstrap-servers, the variable ansible_python_interpreter should be set to the python interpreter installed in virtualenv.