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
```Shell
MOLECULE_LIBRARY_DIR=$(pwd)/library
# If you use custom modules you can specify a git repo containing these files.
# The repo will be cloned so ansible can use it.
MOLECULE_CUSTOM_MODULES_REPO=
MOLECULE_PLUGINS_DIR=$(pwd)/plugins
# If you have custom filters you can specify a git repo containing these files.
MOLECULE_CUSTOM_FILTERS_REPO=
```

View File

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