diff --git a/doc/source/reference/configuration/extending-osa.rst b/doc/source/reference/configuration/extending-osa.rst index f3c1e18770..9583b080bb 100644 --- a/doc/source/reference/configuration/extending-osa.rst +++ b/doc/source/reference/configuration/extending-osa.rst @@ -93,6 +93,19 @@ You can override location of the ``user-collection-requirements.yml`` by setting ``USER_COLLECTION_FILE`` environment variable before running the ``bootstrap-ansible.sh`` script. +Installing extra Python packages inside Ansible virtualenv +---------------------------------------------------------- + +Some Ansible collections may require presence of specific Python libraries +inside execution environment. +In order to accomplish that deployer can create ``/etc/openstack_deploy/user-ansible-venv-requirements.txt`` +file with a list of Python libraries that should be installed inside virtual +environment along with Ansible during ``bootstrap-ansible.sh`` execution. + +You can override the default path to ``user-ansible-venv-requirements.txt`` file +with ``USER_ANSIBLE_REQUIREMENTS_FILE`` environment variable before running the +``bootstrap-ansible.sh`` script. + Maintaining local forks of ansible roles ---------------------------------------- diff --git a/etc/openstack_deploy/user-ansible-venv-requirements.txt.example b/etc/openstack_deploy/user-ansible-venv-requirements.txt.example new file mode 100644 index 0000000000..82beb5c297 --- /dev/null +++ b/etc/openstack_deploy/user-ansible-venv-requirements.txt.example @@ -0,0 +1,5 @@ +# Use this file to fill in your third party libraries that you'd like to have +# installed inside Ansible virtual environment during bootstrap-ansible.sh. +# This file will be processed additionally to default requirements.txt and +# does not superceed it. +oauthlib>=3.2.0 diff --git a/releasenotes/notes/user_requirements_file-4d9f65599ec4d842.yaml b/releasenotes/notes/user_requirements_file-4d9f65599ec4d842.yaml new file mode 100644 index 0000000000..7448a7efeb --- /dev/null +++ b/releasenotes/notes/user_requirements_file-4d9f65599ec4d842.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Implemented installation of extra Python packages inside Ansible virtual + environment. By default, extra requirements should be defined in + ``/etc/openstack_deploy/user-ansible-venv-requirements.txt`` file. Path to the + requirements file can be overriden using ``USER_ANSIBLE_REQUIREMENTS_FILE`` + environment variable. diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index 0ff6e9bd8a..cd10386090 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -25,8 +25,9 @@ export HTTPS_PROXY=${HTTPS_PROXY:-""} export ANSIBLE_PACKAGE=${ANSIBLE_PACKAGE:-"ansible-core==2.15.5"} export ANSIBLE_ROLE_FILE=${ANSIBLE_ROLE_FILE:-"ansible-role-requirements.yml"} export ANSIBLE_COLLECTION_FILE=${ANSIBLE_COLLECTION_FILE:-"ansible-collection-requirements.yml"} -export USER_ROLE_FILE=${USER_ROLE_FILE:-"user-role-requirements.yml"} export USER_COLLECTION_FILE=${USER_COLLECTION_FILE:-"user-collection-requirements.yml"} +export USER_ANSIBLE_REQUIREMENTS_FILE=${USER_ANSIBLE_REQUIREMENTS_FILE:-"${OSA_CONFIG_DIR:-/etc/openstack_deploy}/user-ansible-venv-requirements.txt"} +export USER_ROLE_FILE=${USER_ROLE_FILE:-"user-role-requirements.yml"} export SSH_DIR=${SSH_DIR:-"/root/.ssh"} export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:-"noninteractive"} # check whether to install the ARA callback plugin @@ -122,6 +123,10 @@ elif [ -n "$HTTP_PROXY" ]; then PIP_OPTS+="--proxy $HTTP_PROXY" fi +if [ -f "${USER_ANSIBLE_REQUIREMENTS_FILE}" ]; then + PIP_OPTS+="--requirement $USER_ANSIBLE_REQUIREMENTS_FILE" +fi + PYTHON_EXEC_PATH="${PYTHON_EXEC_PATH:-$(which python3)}" # Obtain the SHA of the upper-constraints to use for the ansible runtime venv