Create symlink to ansible collections on install

Bifrost requires Ansible Collections for certain tasks including
enrollment of nodes. In order for bifrost playbooks to be able to
utilise Ansible Collections, a symlink or an environment variable
needs to point to their install path. This change adds creation of
the symlink to the setup script and a corresponding documentation
update.

Change-Id: I07804a88ed11b0adb6c398743905725c6cdb90d4
This commit is contained in:
Jacob Anders 2020-07-21 23:35:20 +10:00
parent e03d187209
commit c331093a3d
3 changed files with 20 additions and 1 deletions

View File

@ -332,7 +332,9 @@ ansible.cfg) or you can specify the location setting
.. note::
If you are using a virtual environment ANSIBLE_COLLECTIONS_PATHS is
automatically set.
automatically set. After Ansible Collections are installed,
a symbolic link to to the installation is created in the bifrost playbook
directory.
The ``env-setup.sh`` script automatically invokes ``install-deps.sh`` and
creates a virtual environment for you:

View File

@ -0,0 +1,11 @@
---
features:
- |
Added creation of a symbolic link from $VENV/collections directory which
contains ansible collections to the playbooks subdirectory of bifrost.
This is done in the env-setup.sh script.
fixes:
- |
The addition of the symbolic link makes bifrost playbooks independent of
the ANSIBLE_COLLECTIONS_PATHS environment variable which wasn't reliably
set in some environments.

View File

@ -53,6 +53,12 @@ else
${ANSIBLE_GALAXY} collection install -r ${ANSIBLE_COLLECTION_REQ} -p ${BIFROST_COLLECTIONS_PATHS}
fi
# Symlink Collections to the playbook directory. This removes the need of setting
# ANSIBLE_COLLECTIONS_PATHS environment variable
if [ ! -e "$(dirname $0)/../playbooks/collections" ]; then
echo "Creating a symbolic link to ansible collections in bifrost playbook directory"
ln -s ${ANSIBLE_COLLECTIONS_PATHS} "$(dirname $0)/../playbooks/collections"
fi
echo
echo "To use bifrost, do"