-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.sh
executable file
·114 lines (89 loc) · 3.89 KB
/
deploy.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
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
#### Archive files generated from previous deployments
timestamp_folder=./logs/$( date +"%Y-%m-%d-%H-%M-%S" )
echo $timestamp
mkdir $timestamp_folder
mv generatedTemplateFor*.json $timestamp_folder
mv cassandra_ip_pool.txt $timestamp_folder
mv ipListWithHeader.txt $timestamp_folder
mv ipListWithoutHeader.txt $timestamp_folder
##### Retrieve SSH public key name
sshKeyName=$1
##### Retrieve SSH public key's fullpath name
sshPublicKeyFilePath=$2
##### Retrieve the full path of a file storing your Oracle CLI's password
# Make sure you "chmod 600" on it
pwdFilePath=$3
##### Retrieve SSH private key's fullpath name
# Make sure you "chmod 600" on it
sshPrivateKeyFilePath=$4
##### Retrieve Cassandra DB user's password
cassandraPasswd=$5
##### Add public ssh-key to your Oracle Cloud environment
oracle-compute add sshkey $OPC_USER/$sshKeyName $sshPublicKeyFilePath -p $pwdFilePath
##### Building DataStax Cassandra cluster and OpsCenter
# Generate the IP reservation addresses for the DSE Cassandra cluster nodes
python preprocess.py
for i in generatedTemplateForIP_*.json; do
echo $i
oracle-compute add orchestration $i -f json -p $pwdFilePath
sleep 2
done
COUNTER=0
for i in generatedTemplateForIP_*.json; do
echo $i
oracle-compute start orchestration $OPC_USER/DataStax_IP_Reservation_Plan_$COUNTER -p $pwdFilePath
let COUNTER=COUNTER+1
sleep 5
done
sleep 5
oracle-compute list ipreservation $OPC_USER -p $pwdFilePath -F name,ip > ipListWithHeader.txt
sed -e '1,1d' < ipListWithHeader.txt > ipListWithoutHeader.txt
#### Generate storage, compute and master plan OPC CLI orchestration templates
python main.py $sshPublicKeyFilePath $cassandraPasswd
#### Building DSE specific security lists for DSE nodes and associated security rules
oracle-compute add orchestration generatedTemplateForSecurityList.json -f json -p $pwdFilePath
oracle-compute add orchestration generatedTemplateForSecurityRules.json -f json -p $pwdFilePath
oracle-compute start orchestration $OPC_USER/DataStax_Security_Lists_Plan -p $pwdFilePath
oracle-compute start orchestration $OPC_USER/DataStax_Security_Rules_Plan -p $pwdFilePath
#### Adding the orchestration templates and executing them through the Master_Plan orchestrations
# Adding Storage specific orchestration templates
for i in generatedTemplateForStorage_*.json; do
echo $i
oracle-compute add orchestration $i -f json -p $pwdFilePath
sleep 2
done
# Adding Instance specific orchestration templates
for i in generatedTemplateForInstance_*.json; do
echo $i
oracle-compute add orchestration $i -f json -p $pwdFilePath
sleep 2
done
# Adding Master orchestration templates to coordinate storage and instance provisioning sequence
for i in generatedTemplateForMaster_*.json; do
echo $i
oracle-compute add orchestration $i -f json -p $pwdFilePath
sleep 2
done
sleep 10
# Executing Master orchestration template to provision DSE OpsCenter
oracle-compute discover orchestration $OPC_USER -p $pwdFilePath | grep Master_Plan_OpsCenter > generatedTemplateForMasterPlan_OpsCenter.txt
while read line
do
oracle-compute start orchestration $line -p $pwdFilePath
sleep 5
done < generatedTemplateForMasterPlan_OpsCenter.txt
# Call LCM setupCluster.py
opsCenter_ip=$(tail -1 ipListWithoutHeader.txt | awk '{print $2}')
wget https://github.com/DSPN/install-datastax-ubuntu/archive/5.5.3.zip
unzip 5.5.3.zip
cd install-datastax-ubuntu-5.5.3/bin/lcm/
./setupCluster.py --user opc --pause 60 --trys 40 --opsc-ip $opsCenter_ip --clustername test_cluster --privkey $sshPrivateKeyFilePath --datapath /mnt/data1
# Executing Master orchestration templates to provision DSE nodes
cd ../../..
oracle-compute discover orchestration $OPC_USER -p $pwdFilePath | grep Master_Plan_DSE > generatedTemplateForMasterPlans_DSE.txt
while read line
do
oracle-compute start orchestration $line -p $pwdFilePath
sleep 5
done < generatedTemplateForMasterPlans_DSE.txt