-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws_cf_mapr_dsr_single_node.yml
308 lines (299 loc) · 11.5 KB
/
aws_cf_mapr_dsr_single_node.yml
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Setup a MapR cluster'
Parameters:
clusterAdminPassword:
Description: Password for user mapr. User mapr is setup as the cluster admin. You use it to login to the MapR installer UI as well as the web UI of different components. The uid and gid for this user is set to 5000.
Type: String
NoEcho: True
AllowedPattern: ".+"
ConstraintDescription: must provide a password
clusterAdminPasswordConfirm:
Description: Confirm the password you typed in above.
Type: String
NoEcho: True
diskSize:
Description: GB (Total disk allocated will be 3x of the value specified)
Type: Number
Default: 100
instanceType:
Description: AWS Instance types - https://aws.amazon.com/ec2/instance-types
Type: String
AllowedValues: [ m4.2xlarge, m4.4xlarge, m4.10xlarge, m4.16xlarge ]
Default: m4.2xlarge
keyName:
Description: AWS key pair used to create nodes
Type: AWS::EC2::KeyPair::KeyName
AllowedPattern: ".+"
ConstraintDescription: must select an existing EC2 KeyPair
Rules:
MapRPasswordVerify:
Assertions:
- Assert: !Equals [ !Ref clusterAdminPassword, !Ref clusterAdminPasswordConfirm ]
AssertDescription: “Cluster admin passwords do not match"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Node Configuration"
Parameters:
- keyName
- instanceType
- diskSize
-
Label:
default: "MapR Cluster Configuration"
Parameters:
- clusterAdminPassword
- clusterAdminPasswordConfirm
ParameterLabels:
keyName:
default: "AWS Keypair Name"
clusterAdminPassword:
default: "Cluster admin password"
clusterAdminPasswordConfirm:
default: "Verify cluster admin password"
instanceType:
default: "Instance type for node"
diskSize:
default: "Size of disk"
Mappings:
Variables:
Keys:
SSHUSER: "centos"
MAPRCORE: "6.0.0"
MEP: "4.1.0"
# Values for this template
provisioningTemplate: "Converged-Platform"
diskType: "gp2"
CIDR: "0.0.0.0/0"
StanzaURL:
"Converged-Platform":
serviceTemplate: "template-05-converged"
"Data-Lake":
serviceTemplate: "template-10-hadoop"
"Data-Exploration":
serviceTemplate: "template-20-drill"
"Operational-Analytics":
serviceTemplate: "template-30-maprdb2"
"Operational-Analytics-using-MapR-DB":
serviceTemplate: "template-30-maprdb"
"Real-Time-Analytics-with-Spark":
serviceTemplate: "template-60-spark"
"Real-Time-Analytics-with-Streams":
serviceTemplate: "template-40-maprstreams"
RegionMap:
#If you update these AMI, make sure to update the login user used in this template
#Update with AMI before using the template
us-east-1: # N Viriginia
AMI: ami-4bf3d731
us-east-2: # Ohio
AMI: ami-e1496384
us-west-1: # California
AMI: ami-65e0e305
us-west-2: # Oregon
AMI: ami-a042f4d8
ca-central-1: # Québec
AMI: ami-dcad28b8
eu-central-1: # Frankfurt
AMI: ami-337be65c
eu-west-1: # Ireland
AMI: ami-6e28b517
eu-west-2: # London
AMI: ami-ee6a718a
ap-southeast-1: # Singapore
AMI: ami-d2fa88ae
ap-southeast-2: # Sydney
AMI: ami-b6bb47d4
ap-south-1 : # Mumbai
AMI: ami-5d99ce32
ap-northeast-1: # Tokoyo
AMI: ami-25bd2743
ap-northeast-2: # Seoul
AMI: ami-7248e81c
# sa-east-1: # São Paulo
# AMI: ami-7abd0209
Resources:
InstallerSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: "MapR Access"
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '9443'
ToPort: '9443'
CidrIp: !FindInMap [Variables, "Keys", "CIDR"]
- IpProtocol: tcp
FromPort: '8443'
ToPort: '8443'
CidrIp: !FindInMap [Variables, "Keys", "CIDR"]
- IpProtocol: tcp
FromPort: '9995'
ToPort: '9995'
CidrIp: !FindInMap [Variables, "Keys", "CIDR"]
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: !FindInMap [Variables, "Keys", "CIDR"]
InstallWaitHandle:
Type: AWS::CloudFormation::WaitConditionHandle
InstallWaitCondition:
Type: AWS::CloudFormation::WaitCondition
DependsOn: MaprInstaller
Properties:
Handle: !Ref "InstallWaitHandle"
Timeout: "3000"
MaprInstaller:
Type: AWS::EC2::Instance
DependsOn: InstallerSG
Properties:
Tags:
- Key: Name
Value: !Join ["-", [!Ref "AWS::StackName", "dsr"]]
BlockDeviceMappings:
- DeviceName: "/dev/sda1"
Ebs:
DeleteOnTermination: "true"
VolumeSize: 40
- DeviceName: "/dev/sdb"
Ebs:
VolumeType: !FindInMap [Variables, "Keys", "diskType"]
DeleteOnTermination: "true"
VolumeSize: !Ref diskSize
- DeviceName: "/dev/sdc"
Ebs:
VolumeType: !FindInMap [Variables, "Keys", "diskType"]
DeleteOnTermination: "true"
VolumeSize: !Ref diskSize
- DeviceName: "/dev/sdd"
Ebs:
VolumeType: !FindInMap [Variables, "Keys", "diskType"]
DeleteOnTermination: "true"
VolumeSize: !Ref diskSize
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", "AMI"]
KeyName: !Ref keyName
InstanceType: !Ref instanceType
NetworkInterfaces:
- DeleteOnTermination: "true"
DeviceIndex: 0
GroupSet: [ !GetAtt InstallerSG.GroupId ]
AssociatePublicIpAddress: True
UserData:
Fn::Base64: !Sub
- |
#!/bin/bash -x
yum install -y wget
wget http://package.mapr.com/releases/installer/mapr-setup.sh
chmod +x mapr-setup.sh
./mapr-setup.sh -y
MAPR_CORE=${MAPR_CORE}
SSH_USER=${SSH_USER}
M_HOME=/opt/mapr/installer
M_USER_PWD=${clusterAdminPassword}
M_USER=$(grep installer_admin_id "$M_HOME/data/properties.json" | cut -d\" -f4)
M_GROUP=$(grep installer_admin_group "$M_HOME/data/properties.json" | cut -d\" -f4)
echo "$M_USER:$M_USER_PWD" | chpasswd
localipv4=$(curl http://169.254.169.254/latest/meta-data/local-ipv4)
statusFile=$M_HOME/logs/cf_status
if ( $? != 0); then
echo "{ \"Status\" : \"FAILURE\", \"UniqueId\" : \"${AWS::StackName}\", \"Data\" : \"Unable to reset password for $M_USER\", \"Reason\" : \"Unable to reset password for $M_USER\" }" > $statusFile
curl -T $statusFile '${InstallWaitHandle}'
exit 1
fi
$M_HOME/bin/aws/keypair init ${AWS::StackName}
if [ ! -f $M_HOME/data/aws_key ]; then
echo "{ \"Status\" : \"FAILURE\", \"UniqueId\" : \"${AWS::StackName}\", \"Data\" : \"AWS Key file not found. You may be using an old installer.\", \"Reason\" : \"AWS Key file not found. You may be using an old installer.\" }" > $statusFile
curl -T $statusFile '${InstallWaitHandle}'
exit 1
fi
key=$(cat $M_HOME/data/aws_key)
key_file=$M_HOME/data/$key
auth_file=$(getent passwd $SSH_USER | cut -d':' -f6)
cat $key_file.pub >> $auth_file/.ssh/authorized_keys
chown $M_USER:$M_GROUP $key_file
chmod 400 $key_file
input=$M_HOME/conf/stanza_input.yml
echo "environment:" > $input
echo " mapr_core_version: $MAPR_CORE " >> $input
echo "config:" >> $input
echo " mep_version: ${MAPR_MEP} " >> $input
echo " cluster_name: ${AWS::StackName} " >> $input
echo " ssh_id: $SSH_USER " >> $input
echo " ssh_key_file: $key_file " >> $input
echo " disks: [] " >> $input
echo " hosts: " >> $input
echo " - $localipv4 " >> $input
echo " services:" >> $input
echo " ${serviceTemplate}:" >> $input
chown $M_USER:$M_GROUP $input
status="SUCCESS"
data="MapR Installer"
wget -q -t 10 --retry-connrefused --waitretry=30 --no-check-certificate https://localhost:9443/api/swagger.json -O /tmp/swagger.json
cd $M_HOME
cmd="bin/mapr-installer-cli install -f -n -t $input -u $M_USER:$M_USER_PWD@localhost:9443 -o config.cluster_admin_password=$M_USER_PWD -o config.db_admin_password=$M_USER_PWD"
sudo -u $M_USER $cmd || status="FAILURE"
if [ "$status" == "SUCCESS" ]; then
t=$(curl -s -k "https://$M_USER:$M_USER_PWD@localhost:9443/api/config/services?name=mapr-webserver")
p=$(echo $t | sed -e 's/.*"ui_ports":\[\([^,]*\).*/\1/')
data=";"
for h in $(echo $t | sed -e 's/.*"hosts":\[\([^]]*\).*/\1/' | sed -e 's/,/ /g' -e 's/"//g'); do
data+="https://$h:$p "
done
data+=";"
else
reason=$(tail -1 $M_HOME/logs/installer-cli.log)
hostname=$(hostname -f)
[ -z $reason ] && reason="Unable to determine failure reason. Probably failed early provisiong AWS resources. Check installer logs at https://$hostname:9443."
fi
yum install -y docker
service docker start
service docker enable
echo $M_USER_PWD | sudo -u mapr maprlogin password
cat > /root/run_dsr.sh <<EOF
docker run -it -d \
-p 9995:9995 \
-p 10000-10010:10000-10010 \
--cap-add SYS_ADMIN \
--cap-add SYS_RESOURCE \
--device /dev/fuse \
-v /tmp/maprticket_5000:/tmp/maprticket_5000:ro \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-e HOST_IP=$localipv4 \
-e MAPR_CLUSTER=${AWS::StackName} \
-e MAPR_CLDB_HOSTS=$localipv4 \
-e MAPR_CONTAINER_USER=mapr \
-e MAPR_CONTAINER_PASSWORD=$M_USER_PWD \
-e MAPR_CONTAINER_GROUP=mapr \
-e MAPR_CONTAINER_UID=5000 \
-e MAPR_CONTAINER_GID=5000 \
-e MAPR_MOUNT_PATH=/mapr \
-e MAPR_HS_HOST=$localipv4 \
-e MAPR_TICKETFILE_LOCATION=/tmp/maprticket_5000 \
docker.io/maprtech/data-science-refinery
EOF
chmod +x /root/run_dsr.sh
/root/run_dsr.sh &
sleep 120
echo "{ \"Status\" : \"$status\", \"UniqueId\" : \"${AWS::StackName}\", \"Data\" : \"$data\", \"Reason\" : \"$reason\" }" > $statusFile
curl -T $statusFile '${InstallWaitHandle}'
- serviceTemplate: !FindInMap [ StanzaURL, !FindInMap [Variables, "Keys", "provisioningTemplate"], "serviceTemplate" ]
SSH_USER: !FindInMap [Variables, "Keys", "SSHUSER"]
MAPR_CORE: !FindInMap [Variables, "Keys", "MAPRCORE"]
MAPR_MEP: !FindInMap [Variables, "Keys", "MEP"]
Outputs:
ClusterName:
Description: Cluster name
Value: !Ref AWS::StackName
MaprHostIp:
Description: MapR installer IP Address
Value: !GetAtt MaprInstaller.PublicIp
SSHUser:
Description: SSH user to login to the host. SSH with the AWS key pair you provided as input.
Value: !FindInMap [Variables, "Keys", "SSHUSER"]
ZeppelinUrl:
Description: Zeppelin
Value: !Join [ "", ["https://", !GetAtt MaprInstaller.PublicIp, ":9995"]]
MonetUrl:
Description: Monet
Value: !Join [ "", ["https://", !GetAtt MaprInstaller.PublicIp, ":8443"]]