-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnodegroup_app_mini_only.sh
More file actions
executable file
·34 lines (25 loc) · 1.19 KB
/
nodegroup_app_mini_only.sh
File metadata and controls
executable file
·34 lines (25 loc) · 1.19 KB
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
#!/bin/bash
set -e
source /opt/salt-ssh-deploy/.env
# By default exit code = 0
GRAND_EXIT=0
# Duplicate output to temp file and rm it with trap on exit
OUT_FILE=$(mktemp)
trap 'rm -f "${OUT_FILE}"' 0
exec > >(tee ${OUT_FILE})
exec 2>&1
SALT_SSH_NODEGROUP="$1"
DEPLOY_ONLY="$2"
echo "${SALT_REPO_KEY_TOKEN}" | docker login --username "${SALT_REPO_KEY_USER}" --password-stdin "${SALT_REPO_REGISTRY}"
docker run --pull=always --rm -e SALTSSH_ROOT_ED25519_PRIV="$(cat ${SALTSSH_ROOT_ED25519_PRIV_FILE})" -e SALTSSH_ROOT_ED25519_PUB="$(cat ${SALTSSH_ROOT_ED25519_PUB_FILE})" ${SALT_REPO_IMAGE} -- \
salt-ssh --wipe --force-color --nodegroup "${SALT_SSH_NODEGROUP}" \
state.apply app.mini \
pillar='{app: {python: {deploy_only: "'${DEPLOY_ONLY}'"}, php-fpm: {deploy_only: "'${DEPLOY_ONLY}'"}, ruby: {deploy_only: "'${DEPLOY_ONLY}'"}, static: {deploy_only: "'${DEPLOY_ONLY}'"}, docker: {deploy_only: "'${DEPLOY_ONLY}'"}}}' \
|| GRAND_EXIT=1
# Check out file for errors
grep -q "ERROR" ${OUT_FILE} && GRAND_EXIT=1
# Check out file for red color with shades
grep -q "\[0;31m" ${OUT_FILE} && GRAND_EXIT=1
grep -q "\[31m" ${OUT_FILE} && GRAND_EXIT=1
grep -q "\[0;1;31m" ${OUT_FILE} && GRAND_EXIT=1
exit $GRAND_EXIT