From 7bb00a358635389b95ae4b14f92605837d2f481e Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Thu, 23 Dec 2021 23:23:03 -0500 Subject: [PATCH] Add environment check to collection linking script --- Makefile | 8 ++++---- ...cal-collections.bash => link-local-collections.sh | 12 +++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) rename dynamically-link-local-collections.bash => link-local-collections.sh (51%) diff --git a/Makefile b/Makefile index d13d03d..0957a63 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ clean: rm --recursive --force .ansible/ dev: - poetry install --remove-untracked - poetry run pre-commit install - poetry run ansible-galaxy collection install --requirements-file ./requirements.yaml --collections-path ./.ansible - ./dynamically-link-local-collections.bash + @poetry install --remove-untracked + @poetry run pre-commit install + @poetry run ansible-galaxy collection install --requirements-file ./requirements.yaml --collections-path ./.ansible + @bash ./link-local-collections.sh diff --git a/dynamically-link-local-collections.bash b/link-local-collections.sh similarity index 51% rename from dynamically-link-local-collections.bash rename to link-local-collections.sh index c6d8ee0..407c157 100755 --- a/dynamically-link-local-collections.bash +++ b/link-local-collections.sh @@ -15,4 +15,14 @@ for collection_path in "$PWD"/"$ANSIBLE_NAMESPACE"/*; do fi done -echo "Done!" +echo "Finished linking local collections" + +LOCAL_COLLECTION_PATH=$(dirname "$ANSIBLE_COLLECTION_DIR") + +if [ -z ${ANSIBLE_COLLECTIONS_PATH+x} ]; then + echo "WARNING: Environment variable ANSIBLE_COLLECTIONS_PATH is not set, collections will not be callable" + echo " HINT: export ANSIBLE_COLLECTIONS_PATH=$LOCAL_COLLECTION_PATH" +elif [[ ${ANSIBLE_COLLECTIONS_PATH} != *"$LOCAL_COLLECTION_PATH"* ]]; then + echo "WARNING: Environment variable ANSIBLE_COLLECTIONS_PATH does not include local collection directory" + echo " HINT: export ANSIBLE_COLLECTIONS_PATH=\$ANSIBLE_COLLECTIONS_PATH:$LOCAL_COLLECTION_PATH" +fi