forked from openedx-unsupported/configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maintenance.sh
executable file
·42 lines (36 loc) · 1.05 KB
/
maintenance.sh
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
#!/bin/bash
usage() {
echo "Usage: $0 environment-deploy (enable|disable)"
echo
echo "Examples:"
echo " Turn on maintenance page for stage-edx: $0 stage-edx enable"
echo " Turn off maintenance page for stage-edx: $0 stage-edx disable"
exit 1
}
ED=$1
ENABLE_ARG=$2
case $ED in
loadtest-edx|stage-edx|prod-edx|prod-edge)
;;
*)
echo "ERROR: environment-deploy must be one of loadtest-edx, stage-edx, prod-edx or prod-edge"
echo
usage
;;
esac
case $ENABLE_ARG in
enable)
ENABLE="True"
;;
disable)
ENABLE="False"
;;
*)
echo "ERROR: must specify enable or disable"
echo
usage
;;
esac
INVENTORY=$(aws ec2 describe-instances --filter "Name=tag:Name,Values=${ED}-edxapp,${ED}-studio,${ED}-worker" --query 'Reservations[].Instances[].PrivateIpAddress' --output text | tr '\t' ',')
ENABLE_EXTRA_VAR="{\"ENABLE_MAINTENANCE\": ${ENABLE}}"
ansible-playbook ./edx_maintenance.yml -i "${INVENTORY}," -e "${ENABLE_EXTRA_VAR}"