33 lines
1.1 KiB
Bash
Executable File
33 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# shellcheck disable=2039
|
|
set -eo pipefail
|
|
|
|
DIR=$(pwd)
|
|
[ -z "${MOLECULE_LIBRARY_DIR}" ] && MOLECULE_LIBRARY_DIR=${DIR%/}/library
|
|
[ -z "${MOLECULE_PLUGINS_DIR}" ] && MOLECULE_PLUGINS_DIR=${DIR%/}/plugins
|
|
|
|
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 [ -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
|
|
|
|
if [ -n "${MOLECULE_ANSIBLE_VAULT_PASSWORD}" ]; then
|
|
printf "Write vault password file ...\n"
|
|
MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE=/root/.vaultpasswd
|
|
echo "${MOLECULE_ANSIBLE_VAULT_PASSWORD}" > $MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE
|
|
exec env ANSIBLE_VAULT_PASSWORD_FILE=$MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE /usr/local/bin/molecule "$@"
|
|
else
|
|
exec /usr/local/bin/molecule "$@"
|
|
fi
|