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
Robert Kaussow 3e9fbc4ada
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
fix vault password file handling
2020-10-10 11:04:39 +02:00

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