This repository has been archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
menu.sh
executable file
·100 lines (94 loc) · 4.14 KB
/
menu.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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
run_env=""
run_inv=""
run_pb=""
source ./.project
source ./.user
env_options=("gcp" "aws" "esx"
"site_secrets"
"switch_to_gcp" "switch_to_aws" "switch_to_esx")
echo 'Please choose the target environment: '
select opt in "${env_options[@]}"
do
case $opt in
"gcp")
run_env=$opt
run_inv="gcp_inventory.gcp.yml"
break
;;
"aws")
run_env=$opt
# run_inv="ec2.py"
run_inv="aws_ec2.yml"
break
;;
"esx")
run_env=$opt
run_inv="hosts"
break
;;
"site_secrets")
echo Running ansible-vault edit --vault-password-file ../.vault-pass.txt ./vars/site_secrets.yml
ansible-vault edit --vault-password-file ../.vault-pass.txt ./vars/site_secrets.yml
exit 0
;;
"switch_to_gcp")
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt --limit tag_project_${PROJECT},localhost --extra-vars=\"type=gcp run_pb=switch_to_gcp\" switch_to_gcp.yml
ansible-playbook --vault-password-file ../.vault-pass.txt --limit tag_project_${PROJECT},localhost --extra-vars="type=gcp run_pb=switch_to_gcp" switch_to_gcp.yml
exit 0
;;
"switch_to_aws")
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt --limit tag_project_${PROJECT},localhost --extra-vars=\"type=aws run_pb=switch_to_aws\" switch_to_aws.yml
ansible-playbook --vault-password-file ../.vault-pass.txt --limit tag_project_${PROJECT},localhost --extra-vars="type=aws run_pb=switch_to_aws" switch_to_aws.yml
exit 0
;;
"switch_to_esx")
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt --limit tag_project_${PROJECT},localhost --extra-vars=\"type=esx run_pb=switch_to_esx\" switch_to_esx.yml
ansible-playbook --vault-password-file ../.vault-pass.txt --limit tag_project_${PROJECT},localhost --extra-vars="type=esx run_pb=switch_to_esx" switch_to_esx.yml
exit 0
;;
*) echo "invalid option $REPLY";;
esac
done
pb_options=("site" "deploy" "deploy_endpoints"
"jenkins_create_credentials" "deploy_gitlab_runners"
"pause" "pause_scheduled" "pause_scheduled_cancel" "resume"
"terminate" "terminate_site" "configuration" "manual")
echo 'Please choose the playbook: '
select opt in "${pb_options[@]}"
do
run_pb=$opt
break
done
if [ $run_pb = "configuration" ]
then
ansible-vault edit --vault-password-file ../.vault-pass.txt ./configuration.yml
ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars="type=${run_env} run_pb=configurator" configurator.yml
exit 0
fi
if [ $run_pb = "manual" ]
then
pb_manual=( $(find . -maxdepth 1 -name deploy_\*.yml -exec basename {} .yml \; | sort ) )
echo 'Please choose the playbook: '
select opt in "${pb_manual[@]}"
do
run_pb=$opt
break
done
fi
if [ $run_pb = "site" ]
then
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars=\"type=${run_env} run_pb=${run_pb} user=${USER}\" ${run_pb}.yml
ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars="type=${run_env} run_pb=${run_pb} user=${USER}" ${run_pb}.yml
elif [ $run_pb = "pause" ]
then
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars=\"type=${run_env} run_pb=${run_pb} user=${USER}\" ${run_pb}_${run_env}.yml
ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars="type=${run_env} run_pb=${run_pb} user=${USER}" ${run_pb}_${run_env}.yml
elif [ $run_pb = "resume" ]
then
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars=\"type=${run_env} run_pb=${run_pb} user=${USER}\" ${run_pb}_${run_env}.yml
ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars="type=${run_env} run_pb=${run_pb} user=${USER}" ${run_pb}_${run_env}.yml
else
echo Running ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars=\"type=${run_env} run_pb=${run_pb} user=${USER}\" ${run_pb}.yml
ansible-playbook --vault-password-file ../.vault-pass.txt -i ${run_inv} --extra-vars="type=${run_env} run_pb=${run_pb} user=${USER}" ${run_pb}.yml
fi