This repository has been archived on 2024-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
molecule/overlay/bin/molecule

33 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-02-20 16:24:52 +00:00
#!/usr/bin/env sh
# shellcheck disable=2039,3040
set -eo pipefail
2019-11-22 22:31:53 +00:00
DIR=$(pwd)
2020-02-20 22:24:46 +00:00
[ -z "${MOLECULE_LIBRARY_DIR}" ] && MOLECULE_LIBRARY_DIR=${DIR%/}/library
[ -z "${MOLECULE_PLUGINS_DIR}" ] && MOLECULE_PLUGINS_DIR=${DIR%/}/plugins
2020-02-20 22:24:46 +00:00
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
2020-02-20 22:24:46 +00:00
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
2020-10-10 08:22:46 +00:00
if [ -n "${MOLECULE_ANSIBLE_VAULT_PASSWORD}" ]; then
2020-10-10 09:04:39 +00:00
printf "Write vault password file ...\n"
2020-10-10 08:25:53 +00:00
MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE=/root/.vaultpasswd
echo "${MOLECULE_ANSIBLE_VAULT_PASSWORD}" >$MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE
2020-10-10 09:03:48 +00:00
exec env ANSIBLE_VAULT_PASSWORD_FILE=$MOLECULE_ANSIBLE_VAULT_PASSWORD_FILE /usr/local/bin/molecule "$@"
else
exec /usr/local/bin/molecule "$@"
2020-10-10 08:22:46 +00:00
fi