forked from wescale/hashistack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.envrc
69 lines (67 loc) · 1.96 KB
/
.envrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
# Commands dependencies
# =====================
#
DIRENV_CMD_DEPENDENCIES="unzip tar mkdir curl chmod rm"
for mandatory_cmd in ${DIRENV_CMD_DEPENDENCIES}; do
if [ -z "$(which ${mandatory_cmd})" ]; then
echo "===> Mandatory command not found: ${mandatory_cmd}"
exit 1
fi
done
#
# Direnv configuration
# =====================
#
layout_python3
export DIRENV_TMP_DIR="${PWD}/.direnv"
export DIRENV_BIN_DIR="${DIRENV_TMP_DIR}/bin"
if [ ! -e "${DIRENV_BIN_DIR}" ]; then
mkdir -p "${DIRENV_BIN_DIR}"
fi
export PATH="${DIRENV_BIN_DIR}:${PATH}"
DIRENV_PYTHON_LIBS_DIR_RELATIVE="$(find ${DIRENV_TMP_DIR} -type d -name site-packages)"
export DIRENV_PYTHON_LIBS_DIR="$(realpath ${DIRENV_PYTHON_LIBS_DIR_RELATIVE})"
#
# Ansible configuration
# =====================
#
export ANSIBLE_LIBRARY="${PWD}/plugins/modules:${ANSIBLE_LIBRARY}"
export ANSIBLE_SSH_ARGS="-F ${PWD}/ssh.cfg"
export ANSIBLE_INVENTORY="hosts"
export ANSIBLE_COLLECTIONS_PATHS="${DIRENV_TMP_DIR}"
#
# Environment configuration
# =========================
#
#
ENV_ADDONS=".env.local .env.secrets"
for addon in ${ENV_ADDONS}; do
if [ -e "${PWD}/${addon}" ]; then
source ${PWD}/${addon}
fi
done
#
# Terraform CLI installation
# ==========================
#
TF_VERSION="1.1.3"
TF_ARCH="linux_amd64"
TF_PKG_NAME="terraform_${TF_VERSION}_${TF_ARCH}.zip"
TF_PKG_URL="https://releases.hashicorp.com/terraform/${TF_VERSION}/${TF_PKG_NAME}"
TF_PKG_PATH="${DIRENV_TMP_DIR}/${TF_PKG_NAME}"
if [ ! -e "${DIRENV_BIN_DIR}/terraform" ]; then
echo "===> Getting terraform:${TF_VERSION}:${TF_ARCH} (can take a while to execute)"
curl -s -L "${TF_PKG_URL}" -o "${TF_PKG_PATH}"
unzip ${TF_PKG_PATH} -d ${DIRENV_BIN_DIR}
chmod 700 ${DIRENV_BIN_DIR}/terraform
rm -f ${TF_PKG_PATH}
fi
#
# Terraform CLI configuration
# ==========================
#
export TF_PLUGIN_CACHE_DIR="${DIRENV_TMP_DIR}/terraform-plugin-cache"
if [ ! -e "${TF_PLUGIN_CACHE_DIR}" ]; then
mkdir -p "${TF_PLUGIN_CACHE_DIR}"
fi