-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
41 lines (34 loc) · 906 Bytes
/
init.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
#!/bin/sh
function UNSETER() {
LOAD=`alias |grep ansible |wc -l`
if [ $LOAD -gt 0 ]
then
unalias ansible-playbook
fi;
unset ANSIBLE_HOSTS
unset DO_REGION
unset DO_API_TOKEN
unset DO_API_KEY
}
case "$1" in
prod)
#echo "Staring $1 env"
UNSETER
export DO_API_KEY=`cat /etc/ansible/keys/do_token |grep DO_API_KEY |awk -F"=" '{print $2}'`
export DO_REGION=`cat /etc/ansible/keys/do_token |grep DO_API_KEY |awk -F"=" '{print $2}'`
export ANSIBLE_HOSTS="/etc/ansible/inventory/digital_ocean.sh"
export SD_ENV="$1"
alias ansible-playbook='/usr/local/bin/ansible-playbook -u root'
#echo "$1 env is active"
;;
test)
#echo "Staring $1 env"
UNSETER
export DO_REGION=``
export SD_ENV="$1"
alias ansible-playbook='/usr/local/bin/ansible-playbook -u root'
#echo "$1 env is active"
;;
*) echo "usage: source ./init.sh [prod|test]"
;;
esac