-
Notifications
You must be signed in to change notification settings - Fork 105
/
main-installer.sh
executable file
·474 lines (429 loc) · 13.3 KB
/
main-installer.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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
#!/bin/bash
#########################################################################
# File Name: wang.sh
# Author: meetbill
# mail: [email protected]
# Created Time: 2017-07-17 20:51:47
# Unattended installer for Openstack
#########################################################################
unset LANG
unset LANGUAGE
LC_ALL=C
export LC_ALL
# Make sure umask is sane
umask 022
# Keep track of the openstack-newton-scripts directory
TOP_DIR=$(cd $(dirname "$0") && pwd)
#{{{enable_private_repos
enable_private_repos()
{
if [[ $USE_PRIVATE_REPOS == "yes" ]]
then
# Backup repository configs.
cd /etc/yum.repos.d
for i in $(ls *.repo); do mv $i $i.orig; done
cd $TOP_DIR
echo ""
echo "### ERROR: Use Your Private Repos"
echo ""
cp /etc/openstack-control-script-config/private.repo /etc/yum.repos.d/
yum clean all -y
fi
}
#}}}
#{{{install_controller
install_controller()
{
if [[ -z $CONTROLLER_NODES_IP ]]
then
echo ""
echo "### ERROR: Please config your controller nodes's ip address"
echo ""
exit 1
else
echo ""
echo "### INSTALL CONTROLLER NODES"
echo ""
sleep 5
#
# Install requirement ENVIRONMENTs
# - NTP serivce
# - SQL database
# - Memcached
#
$TOP_DIR/scripts/controller/environment.sh
if [[ -f /etc/openstack-control-script-config/environment-installed ]]
then
echo ""
echo "### OPENSTACK ENVIRONMENT INSTALLED"
echo ""
else
echo ""
echo "### ERROR:OPENSTACK ENVIRONMENT INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
#
# Install Keystone service
#
if [[ $INSTALL_KEYSTONE == "yes" ]]
then
$TOP_DIR/scripts/controller/install_keystone.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/keystone-installed ]]
then
echo ""
echo "### OPENSTACK KEYSTONE INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK KEYSTONE INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
fi
#
# Install Glance service
#
if [[ $INSTALL_GLANCE == "yes" ]]
then
$TOP_DIR/scripts/controller/install_glance.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/glance-installed ]]
then
echo ""
echo "### OPENSTACK GLANCE INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK GLANCE INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
fi
#
# Install Nova service
#
if [[ $INSTALL_NOVA == "yes" ]]
then
$TOP_DIR/scripts/controller/install_nova.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/nova-installed ]]
then
echo ""
echo "### OPENSTACK NOVA INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK NOVA INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
fi
#
# Install Neutron service
#
if [[ $INSTALL_NEUTRON == "yes" ]]
then
case $ML2_PLUGIN in
openvswitch)
#
# Install Neutron service with OpenVSwitch
#
$TOP_DIR/scripts/controller/install_neutron_openvswitch.sh
if [[ -f /etc/openstack-control-script-config/neutron-openvswitch-installed ]]
then
echo ""
echo "### OPENSTACK NEUTRON INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK NEUTRON INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
;;
linuxbridge)
#
# Install Neutron service with LinuxBridge
#
$TOP_DIR/scripts/controller/install_neutron_linuxbridge.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/neutron-linuxbridge-installed ]]
then
echo ""
echo "### OPENSTACK NEUTRON INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK NEUTRON INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
;;
*)
echo ""
echo "### ERROR:Wrong ML2_PLUGIN variable, config this variable with 'openvswitch'"
echo "### or 'linuxbridge'"
echo ""
exit 1
;;
esac
sync
sleep 5
sync
fi
#
# Install Horizon service
#
if [[ $INSTALL_HORIZON == "yes" ]]
then
$TOP_DIR/scripts/controller/install_horizon.sh
if [[ -f /etc/openstack-control-script-config/horizon-installed ]]
then
echo ""
echo "### OPENSTACK HORIZON INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK HORIZON INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
fi
#
# Install Cinder service
#
if [[ $INSTALL_CINDER == "yes" ]]
then
$TOP_DIR/scripts/controller/install_cinder.sh
if [[ -f /etc/openstack-control-script-config/cinder-installed ]]
then
echo ""
echo "### OPENSTACK CINDER INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK CINDER INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
fi
fi
}
#}}}
#{{{install_compute
install_compute()
{
#
# Install Compute Nodes
#
HOSTNAME=`hostname`
if [[ -z $COMPUTE_NODES ]] || [[ $COMPUTE_NODES != *$HOSTNAME* ]]
then
echo ""
echo "### WRONG CONFIG - $HOSTNAME NOT IN $COMPUTE_NODES"
echo ""
exit 0
fi
if [[ -z $COMPUTE_NODES_IP ]] || [[ $COMPUTE_NODES != *$HOSTNAME* ]]
then
echo ""
echo "### You don't setup any compute nodes."
echo "### It'll be All-in-one architecture."
echo ""
else
echo ""
echo "### INSTALL COMPUTE NODES - $HOSTNAME"
echo ""
sync
sleep 5
sync
#
# Install requirement environments.
# - NTP service.
#
$TOP_DIR/scripts/compute/environment.sh
if [[ -f /etc/openstack-control-script-config/environment-compute-installed ]]
then
echo ""
echo "### OPENSTACK ENVIRONMENT COMPUTE $HOSTNAME INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK ENVIRONMENT COMPUTE $HOSTNAME INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
#
# Install Nova service
#
$TOP_DIR/scripts/compute/install_nova.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/nova-compute-installed ]]
then
echo ""
echo "### OPENSTACK NOVA COMPUTE $HOSTNAME INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK NOVA COMPUTE $HOSTNAME INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
#
# Install Neutron service
#
if [[ $INSTALL_NEUTRON == "yes" ]]
then
case $ML2_PLUGIN in
openvswitch)
#
# Install Neutron service with OpenVSwitch
#
$TOP_DIR/scripts/compute/install_neutron_openvswitch.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/neutron-openvswitch-compute-installed ]]
then
echo ""
echo "### OPENSTACK NEUTRON $HOSTNAME INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK NEUTRON $HOSTNAME INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
;;
linuxbridge)
#
# Install Neutron service with LinuxBridge
#
$TOP_DIR/scripts/compute/install_neutron_linuxbridge.sh ${DEPLOY_OP}
if [[ -f /etc/openstack-control-script-config/neutron-linuxbridge-compute-installed ]]
then
echo ""
echo "### OPENSTACK NEUTRON $HOSTNAME INSTALLED"
echo ""
else
echo ""
echo "### ERROR: OPENSTACK NEUTRON $HOSTNAME INSTALLATION FAILED. ABORTING !!"
echo ""
exit 0
fi
;;
*)
echo ""
echo "### ERROR:Wrong ML2_PLUGIN variable, config this variable with 'openvswitch'"
echo "### or 'linuxbridge'"
echo ""
exit 1
;;
esac
sync
sleep 5
sync
fi
fi
}
#}}}
#{{{main
main()
{
echo ""
echo "######################################################################################"
echo "OPENSTACK UNATTENDED INSTALLER"
echo "Flavor: OpenStack Mitaka for Centos 7"
echo "Version 1.1.1 2017/10/02"
echo ""
echo "I'll verify all requiremens"
echo "If any requirement is not met, I'll stop and inform what's missing"
echo ""
echo "Requirements"
echo "- OS: Centos 7 x86_64 fully updated"
echo "- This script must be executed by root account (don't use sudo please)"
echo "- Centos 7 original repositories must be enabled and available"
echo "- Make sure you already setup etc/main-config.rc file"
echo ""
echo "NOTE: You can use the tee command if you want to log all installer actions. Example:"
echo "./main-installer.sh | tee -a /var/log/my_install_log.log"
echo "######################################################################################"
echo ""
sleep 5
#
# Check supper user
#
if [[ $(id -u) -ne 0 ]]
then
clear
echo "### ERROR: User is not permission. Please use root."
exit 1
fi
#
# Check main-config.rc file
#
if [[ -f $TOP_DIR/etc/main-config.rc ]]
then
mkdir -p /etc/openstack-control-script-config/
cp -rf etc/* /etc/openstack-control-script-config/
source /etc/openstack-control-script-config/main-config.rc
date > /etc/openstack-control-script-config/install-init-date-and-time
chown -R root.root *
find . -name "*" -type f -exec chmod 644 "{}" ";"
find . -name "*.sh" -type f -exec chmod 755 "{}" ";"
else
echo ""
echo "### ERROR:I can't access my own configuration"
echo "### Please check you are executing the installer in its correct directory"
echo "### Aborting !!!!."
echo ""
exit 1
fi
#
# Enable private repository
#
enable_private_repos
NODE_TYPE=$1
case $NODE_TYPE in
controller*|Controller*|CONTROLLER*)
install_controller
;;
compute*|Compute*|COMPUTE*)
install_compute
;;
*)
echo ""
echo "### Usage: ./main-installer.sh controller|compute... "
echo ""
exit 0
;;
esac
sync
sleep 5
sync
echo ""
echo "###################################################"
echo "Thanks for using scripts."
echo "OPENSTACK INSTALLATION FINISHED"
echo "- Openstack Horizon Link: http://$CONTROLLER_NODES_IP/dashboard/"
echo "- User login Horizon: admin"
echo "- Password user admin: $ADMIN_PASS"
echo "- Password $MYSQLDB_ADMIN user Database MariaDB: $MYSQLDB_PASSWORD"
echo "File Admin Script Openstack: $ADMIN_RC_FILE"
echo "###################################################"
}
#}}}
USAGE="USAGE: $0 controller|compute install|config|check"
if [ $# != 2 ]
then
echo "version:1.0.2"
echo "USAGE: $0 controller|compute install|config|check"
exit 1;
fi
DEPLOY_ROLE=$1
DEPLOY_OP=$2
usage="$0 install/config/check"
case ${DEPLOY_OP} in
install|config|check)
echo "deploy op is ${DEPLOY_OP}"
;;
*)
echo ${USAGE}
exit 1
;;
esac
main ${DEPLOY_ROLE}