-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-cluster-2.sh
159 lines (152 loc) · 5.51 KB
/
setup-cluster-2.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
cd ~
rm --force ./setup-cluster.log
exec > >(tee --append ./setup-cluster.log)
exec 2>&1
date
echo "Read the options"
TEMP=`getopt -o s:g:n:v:d:b:l:w:x:y:z:p:i --long subscription-id:,resource-group:,num-nodes:,vm-sku:,num-disks:,disk-size-gb:,location:,vnet:,vnet-cidr:,subnet:,subnet-cidr:,profile:,nameservice-id: -- "$@"`
eval set -- "$TEMP"
echo "Extract options and their arguments into variables"
while true ; do
case "$1" in
-s|--subscription-id)
subscriptionId=$2 ; shift 2;;
-g|--resource-group)
resourceGroup=$2 ; shift 2;;
-n|--num-nodes)
numNodes=$2 ; shift 2;;
-v|--vm-sku)
vmSku=$2 ; shift 2;;
-d|--num-disks)
numDisks=$2 ; shift 2;;
-b|--disk-size-gb)
diskSizeGb=$2 ; shift 2;;
-l|--location)
location=$2 ; shift 2;;
-w|--vnet)
vnet=$2 ; shift 2;;
-x|--vnet-cidr)
vnetCidr=$2 ; shift 2;;
-y|--subnet)
subnet=$2 ; shift 2;;
-z|--subnet-cidr)
subnetCidr=$2 ; shift 2;;
-p|--profile)
profile=$2 ; shift 2;;
-i|--nameservice-id)
nameserviceId=$2 ; shift 2;;
--) shift ; break ;;
*) echo "ERROR: Unable to get variables from arguments" ; exit 1 ;;
esac
done
if [ -z "$subscriptionId" ]
then
echo "Missing required argument: -s | subscription-id"
exit 1
fi
if [ -z "$resourceGroup" ]
then
echo "Missing required argument: -g | resource-group"
exit 1
fi
if [ -z "$numNodes" ]
then
echo "Missing required argument: -n | num-nodes"
exit 1
fi
if [ -z "$vmSku" ]
then
echo "Missing required argument: -v | vm-sku"
exit 1
fi
if [ -z "$numDisks" ]
then
echo "Missing required argument: -d | num-disks"
exit 1
fi
if [ -z "$diskSizeGb" ]
then
echo "Missing required argument: -b | disk-size-gb"
exit 1
fi
if [ -z "$location" ]
then
echo "Missing required argument: -l | location"
exit 1
fi
if [ -z "$vnet" ]
then
echo "Missing required argument: -w | vnet"
exit 1
fi
if [ -z "$vnetCidr" ]
then
echo "Missing required argument: -x | vnet-cidr"
exit 1
fi
if [ -z "$subnet" ]
then
echo "Missing required argument: -y | subnet"
exit 1
fi
if [ -z "$subnetCidr" ]
then
echo "Missing required argument: -z | subnet-cidr"
exit 1
fi
if [ -z "$profile" ]
then
echo "Missing required argument: -p | profile"
exit 1
fi
if [ -z "$nameserviceId" ]
then
echo "Missing required argument: -i | nameservice-id"
exit 1
fi
echo "Install Python 3.6 and create a virtual environment"
sudo yum install -y epel-release
sudo yum install -y python36 python36-devel python36-setuptools
sudo python36 /usr/lib/python3.6/site-packages/easy_install.py pip
python3.6 -m venv ~/env
source ~/env/bin/activate
echo "Install Ansible and VMSS (virtual machine scale set) patch"
sudo yum check-update
sudo yum install -y gcc libffi-devel python-devel openssl-devel
sudo yum install -y python-pip python-wheel
pip install ansible[azure]
sudo yum -y install git
git clone https://github.com/ansible/ansible
cp ansible/lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py env/lib/python3.6/site-packages/ansible/modules/cloud/azure/
echo "Download the Magna Carta repo zip"
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -q -N ""
mkdir ~/fluo-muchos
wget https://roalexan.blob.core.windows.net/accumulo/fluo-muchos.zip --output-document ~/fluo-muchos/fluo-muchos.zip
unzip ~/fluo-muchos/fluo-muchos.zip -d ~/fluo-muchos
chmod +x ~/fluo-muchos/bin/muchos
chmod +x ~/fluo-muchos/ansible/scripts/install_ansible.sh
echo "Install Azure CLI"
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'
sudo yum install -y azure-cli
sed -i '/^PYTHONPATH=/c\PYTHONPATH=/usr/lib64/az/lib/python2.7/site-packages python2 -sm azure.cli "$@"' $(which az)
echo "Update muchos.props"
/bin/cp ~/fluo-muchos/conf/muchos.props.example ~/fluo-muchos/conf/muchos.props
sed -i "/^cluster_type =/c\cluster_type = azure" ~/fluo-muchos/conf/muchos.props
sed -i "/^cluster_user =/c\cluster_user = rba1" ~/fluo-muchos/conf/muchos.props
sed -i "/^hadoop_version =/c\hadoop_version = 3.2.0" ~/fluo-muchos/conf/muchos.props
sed -i "/^spark_version =/c\spark_version = 2.4.3" ~/fluo-muchos/conf/muchos.props
sed -i "/^accumulo_version =/c\accumulo_version = 2.0.0" ~/fluo-muchos/conf/muchos.props
sed -i "/^resource_group =/c\resource_group = $resourceGroup" ~/fluo-muchos/conf/muchos.props
sed -i "/^vnet =/c\vnet = $vnet" ~/fluo-muchos/conf/muchos.props
sed -i "/^vnet_cidr =/c\vnet_cidr = $vnetCidr" ~/fluo-muchos/conf/muchos.props
sed -i "/^subnet =/c\subnet = $subnet" ~/fluo-muchos/conf/muchos.props
sed -i "/^subnet_cidr =/c\subnet_cidr = $subnetCidr" ~/fluo-muchos/conf/muchos.props
sed -i "/^numnodes =/c\numnodes = $numNodes" ~/fluo-muchos/conf/muchos.props
sed -i "/^vm_sku =/c\vm_sku = $vmSku" ~/fluo-muchos/conf/muchos.props
sed -i "/^location =/c\location = $location" ~/fluo-muchos/conf/muchos.props
sed -i "/^numdisks =/c\numdisks = $numDisks" ~/fluo-muchos/conf/muchos.props
sed -i "/^disk_size_gb =/c\disk_size_gb = $diskSizeGb" ~/fluo-muchos/conf/muchos.props
sed -i "/^profile=/c\profile=$profile" ~/fluo-muchos/conf/muchos.props
sed -i "/^nameservice_id =/c\nameservice_id = $nameserviceId" ~/fluo-muchos/conf/muchos.props