rework molecule wrapper
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Robert Kaussow 2020-02-20 23:24:46 +01:00
parent c4f40ca5c1
commit 54f309d432
2 changed files with 19 additions and 14 deletions

View File

@ -9,10 +9,15 @@ Docker image to automate Ansible deployment tests with Molecule. The image was b
## Environment variables ## Environment variables
```Shell ```Shell
MOLECULE_LIBRARY_DIR=$(pwd)/library
# If you use custom modules you can specify a git repo containing these files. # If you use custom modules you can specify a git repo containing these files.
# The repo will be cloned so ansible can use it. # The repo will be cloned so ansible can use it.
MOLECULE_CUSTOM_MODULES_REPO= MOLECULE_CUSTOM_MODULES_REPO=
MOLECULE_PLUGINS_DIR=$(pwd)/plugins
# If you have custom filters you can specify a git repo containing these files. # If you have custom filters you can specify a git repo containing these files.
MOLECULE_CUSTOM_FILTERS_REPO= MOLECULE_CUSTOM_FILTERS_REPO=
``` ```

View File

@ -2,23 +2,23 @@
set -eo pipefail set -eo pipefail
DIR=$(pwd) DIR=$(pwd)
LIBRARY_DIR=${DIR%/}/library/ [ -z "${MOLECULE_LIBRARY_DIR}" ] && MOLECULE_LIBRARY_DIR=${DIR%/}/library
FILTERS_DIR=${DIR%/}/plugins/filters/ [ -z "${MOLECULE_PLUGINS_DIR}" ] && MOLECULE_PLUGINS_DIR=${DIR%/}/plugins
if [ "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then if [ -n "${MOLECULE_CUSTOM_MODULES_REPO}" ]; then
echo "Cloning custom modules..." printf "Cloning custom modules ...\n"
[ -d "${iLIBRARY_DIR}" ] && rm -rf "${LIBRARY_DIR}" WORKDIR="${MOLECULE_LIBRARY_DIR}"
mkdir -p "${LIBRARY_DIR}" [ -d "$WORKDIR" ] && rm -rf "$WORKDIR"
git clone "${MOLECULE_CUSTOM_MODULES_REPO}" "{LIBRARY_DIR}" 2> /dev/null mkdir -p "$WORKDIR"
echo git clone "$MOLECULE_CUSTOM_MODULES_REPO" "$WORKDIR" 2> /dev/null
fi fi
if [ "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then if [ -n "${MOLECULE_CUSTOM_FILTERS_REPO}" ]; then
echo "Cloning custom filters..." WORKDIR="${MOLECULE_PLUGINS_DIR}/filter"
[ -d "${FILTERS_DIR}" ] && rm -rf "${FILTERS_DIR}" printf "Cloning custom filters ...\n"
mkdir -p "${FILTERS_DIR}" [ -d "$WORKDIR" ] && rm -rf "$WORKDIR"
git clone "$MOLECULE_CUSTOM_FILTERS_REPO" "${FILTERS_DIR}" 2> /dev/null mkdir -p "$WORKDIR"
echo git clone "$MOLECULE_CUSTOM_FILTERS_REPO" "$WORKDIR" 2> /dev/null
fi fi
exec /usr/local/bin/molecule "$@" exec /usr/local/bin/molecule "$@"