-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxpand-one-node.yaml
262 lines (241 loc) · 8.51 KB
/
xpand-one-node.yaml
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
AWSTemplateFormatVersion: '2010-09-09'
Description: Template to Create an EC2 instance in a VPC
Parameters:
ImageIdXpand:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::ImageIdXpand>'
Description: YOUR_IMAGE_ID
Default: ImageIdXpand
VpcId:
Type: String
Description: VPC id
Default: vpc-07377e6c
SubnetId:
Type: String
Description: Subnet in which to launch an EC2
Default: subnet-06377e6d
AvailabilityZone:
Type: String
Description: Availability Zone into which instance will launch
Default: us-west-2a
InstanceType:
Type: String
Description: Choosing i3.4xlarge because need nvme - cost 1.248/hr
Default: i3.4xlarge
KeyName:
Type: AWS::EC2::KeyPair::KeyName
Description: SSH Keypair to login to the instance
Default: mmalgeri777-keypair-mdb
MyIp:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::MyIp>'
Description: MY_IP
Default: MyIp
XpandIpRange:
Type: String
Description: Xpand Ip Range
Default: 172.31.32.0/20
xpandIp7:
Type: String
Description: Demo Xpand Ip 7
Default: 172.31.42.27
xpandToken:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandToken>'
Description: YOUR_TOKEN
Default: xpandToken
xpandLicenseSignature:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandLicenseSignature>'
Description: YOUR_LICENSE_SIGNATURE
Default: xpandLicenseSignature
xpandLicenseEmail:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandLicenseEmail>'
Description: YOUR_LICENSE__EMAIL
Default: xpandLicenseEmail
xpandLicensePerson:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandLicensePerson>'
Description: YOUR_LICENSE_PERSON
Default: xpandLicensePerson
xpandLicenseCompany:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandLicenseCompany>'
Description: YOUR_LICENSE_COMPANY
Default: xpandLicenseCompany
xpandLicenseExpiration:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandLicenseExpiration>'
Description: YOUR_LICENSE_EXPIRATION
Default: xpandLicenseExpiration
xpandPassword:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandPassword>'
Description: YOUR_PASSWORD
Default: xpandPassword
xpandVersion:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandVersion>'
Description: YOUR_XPAND_VERSION
Default: xpandVersion
xpandVersionDir:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::KeyPair::xpandVersionDir>'
Description: YOUR_XPAND_VERSION_DIR
Default: xpandVersionDir
Resources:
xpand7:
Type: 'AWS::EC2::Instance'
Properties:
ImageId: !Ref ImageIdXpand
InstanceType: !Ref InstanceType
AvailabilityZone: !Ref AvailabilityZone
KeyName: !Ref KeyName
NetworkInterfaces:
- DeviceIndex: 0
PrivateIpAddress: !Ref xpandIp7
DeleteOnTermination: true
SubnetId: !Ref SubnetId
GroupSet:
- !Ref DemoSecurityGroup
- !Ref DemoHttpSecurityGroup
Tags:
- Key: Name
Value: xpand7
UserData:
Fn::Base64: !Sub |
#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
echo "Change centos password"
echo -e "${xpandPassword}\n${xpandPassword}" | sudo passwd centos
echo "Installing Xpand software"
yum -y update
echo "Updated yum"
echo "get private ip address"
ip=$(hostname -i)
echo "private address is "
echo $ip
sudo yum -y install bzip2 mdadm nmap ntp ntpdate screen sysstat wget xz git
echo "Installed base level software on xpand7"
echo "Creating raid devices, filesystem, data directory, and mounting"
sudo mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/nvme0n1 /dev/nvme1n1
sudo mkfs.ext4 /dev/md0
sudo mkdir /data
sudo mount /dev/md0 /data
sudo echo "/dev/md0 /data ext4 defaults,noatime,nodiratime 0 1" >> /etc/fstab
sudo systemctl enable ntpd
sudo systemctl start ntpd
echo "Done creating raid devices, filesystem, data directory, and mounting"
echo "Also started ntpd"
echo "Getting xpand software"
sudo wget https://dlm.mariadb.com/${xpandToken}/xpand/${xpandVersionDir}/${xpandVersion}.tar.bz2
cd /
sudo tar xvf ${xpandVersion}.tar.bz2
cd /${xpandVersion}
sudo ./xpdnode_install.py -y
echo "Done running python install script. Can test GUI on port 8080"
echo "Now get mariadb repo"
cd /
sudo wget https://dlm.mariadb.com/enterprise-release-helpers/mariadb_es_repo_setup
sudo chmod +x mariadb_es_repo_setup
./mariadb_es_repo_setup --token=${xpandToken} --apply --mariadb-server-version="10.6"
sudo yum -y install MariaDB-client
sudo chmod 777 /home/xpand/.bash_profile
sudo echo "PATH=$PATH:/opt/clustrix/bin; export PATH" >> /home/xpand/.bash_profile
echo "Change xpand user password"
echo -e "${xpandPassword}\n${xpandPassword}" | sudo passwd xpand
sudo chmod 777 /home/xpand
echo "Confirm SSH daemon configuration"
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords no/g' /etc/ssh/sshd_config
sudo awk '/#PasswordAuthentication yes/{print "PubkeyAuthentication yes"}1' /etc/ssh/sshd_config > /tmp/sshd_config
sudo mv /tmp/sshd_config /etc/ssh
echo "Restarting sshd"
sudo systemctl restart sshd
echo "Installing expect"
sudo yum -y install expect
echo "Running an expect script to install public keys"
/usr/bin/expect -c '
expect <<- DONE
spawn clx pubkeyinstall
expect "?Enter SSH*"
send -- "${xpandPassword}\r"
expect eof
DONE'
echo "Done installing public keys"
DemoSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref VpcId
GroupDescription: SG to allow SSH access via port 22
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: !Ref MyIp
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '3306'
ToPort: '3306'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '3581'
ToPort: '3581'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '2048'
ToPort: '2048'
CidrIp: !Ref XpandIpRange
- IpProtocol: udp
FromPort: '2048'
ToPort: '2048'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '2424'
ToPort: '2424'
CidrIp: !Ref XpandIpRange
- IpProtocol: udp
FromPort: '2424'
ToPort: '2424'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '7888'
ToPort: '7888'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '3581'
ToPort: '3581'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '8989'
ToPort: '8989'
CidrIp: !Ref XpandIpRange
- IpProtocol: tcp
FromPort: '24378'
ToPort: '24410'
CidrIp: !Ref XpandIpRange
- IpProtocol: udp
FromPort: '24378'
ToPort: '24410'
CidrIp: !Ref XpandIpRange
Tags:
- Key: Name
Value: SSH-SG
DemoHttpSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref VpcId
GroupDescription: SG to allow HTTP access via port 80
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: !Ref MyIp
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: !Ref MyIp
Tags:
- Key: Name
Value: SSH-HTTPD
Outputs:
DemoInstanceId:
Description: Instance Id
Value: !Ref xpand7