-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·76 lines (66 loc) · 2.55 KB
/
start.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
#!/usr/bin/env bash
if [ "$1" == "apply" ]
then
echo "--- Starting Terraform ..."
terraform -chdir=terraform init
terraform -chdir=terraform apply -auto-approve
vm_ip1=$(terraform -chdir=terraform output external_ip_address_vm_1)
vm_ip2=$(terraform -chdir=terraform output external_ip_address_vm_2)
vm_ip3=$(terraform -chdir=terraform output external_ip_address_vm_3)
echo "--- Terraform Output ..."
echo "$vm_ip1"
echo "$vm_ip2"
echo "$vm_ip3"
fi
if [ "$1" == "destroy" ]
then
echo "--- Starting Terraform ..."
terraform -chdir=terraform destroy -auto-approve
fi
if [ "$1" == "play" ]
then
vm_ip1=$(terraform -chdir=terraform output external_ip_address_vm_1)
vm_ip2=$(terraform -chdir=terraform output external_ip_address_vm_2)
vm_ip3=$(terraform -chdir=terraform output external_ip_address_vm_3)
echo "--- Using IP adresses ..."
echo "$vm_ip1"
echo "$vm_ip2"
echo "$vm_ip3"
ansible-playbook -i playbook/inventory/prod.yml playbook/site.yml -e vmip1=$vm_ip1 -e vmip2=$vm_ip2 -e vmip3=$vm_ip3 --diff && echo "--- All ok. Check the service! "
fi
if [ "$1" == "play-vector" ]
then
vm_ip1=$(terraform -chdir=terraform output external_ip_address_vm_1)
vm_ip2=$(terraform -chdir=terraform output external_ip_address_vm_2)
vm_ip3=$(terraform -chdir=terraform output external_ip_address_vm_3)
echo "--- Using IP adresses ..."
echo "$vm_ip1"
echo "$vm_ip2"
echo "$vm_ip3"
ansible-playbook -i playbook/inventory/prod.yml playbook/site.yml -e vmip1=$vm_ip1 -e vmip2=$vm_ip2 -e vmip3=$vm_ip3 --diff --tags vector && echo "--- All ok. Check the service! "
fi
if [ "$1" == "check" ]
then
vm_ip1=$(terraform -chdir=terraform output external_ip_address_vm_1)
vm_ip2=$(terraform -chdir=terraform output external_ip_address_vm_2)
vm_ip3=$(terraform -chdir=terraform output external_ip_address_vm_3)
echo "--- Using IP adresses ..."
echo "$vm_ip1"
echo "$vm_ip2"
echo "$vm_ip3"
ansible-playbook -i playbook/inventory/prod.yml playbook/site.yml -e vmip1=$vm_ip1 -e vmip2=$vm_ip2 -e vmip3=$vm_ip3 --check
fi
if [ "$1" == "showip" ]
then
vm_ip1=$(terraform -chdir=terraform output external_ip_address_vm_1)
vm_ip2=$(terraform -chdir=terraform output external_ip_address_vm_2)
vm_ip3=$(terraform -chdir=terraform output external_ip_address_vm_3)
echo "--- Using IP adresses ..."
echo "$vm_ip1"
echo "$vm_ip2"
echo "$vm_ip3"
fi
if [ "$1" == "installroles" ]
then
ansible-galaxy install -r playbook/requirements.yml -p playbook/roles
fi