blob: 4c7666b9973c3a5f82da3a318e76a43d8c1a741b (
plain)
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
|
#!/bin/bash
# Copyright (C) 2023 Pasha <pasha@member.fsf.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
OPENSTACK_HOST_IP="192.168.0.155"
EXTERNAL_BRIDGE_INTERFACE="eno1"
MY_USER_NAME="openstack"
MY_USER_PASS="openstack"
if [ -z ${OPENSTACK_HOST_IP} ]; then
echo "Please set OpenStack host IP"
exit 1
fi
if [ -z ${EXTERNAL_BRIDGE_INTERFACE} ]; then
echo "Please set external bridge interface name"
exit 1
fi
OPENSTACK_HOST=$HOSTNAME
CONFIG_DIR="configs"
export DEBIAN_FRONTEND=noninteractive
function download_packages() {
echo "downloading packages..."
apt-get -dy install chrony mariadb-server python3-pymysql rabbitmq-server memcached python3-memcache etcd keystone apache2 python3-openstackclient glance placement-api libguestfs-tools virt-manager nova-api nova-conductor nova-novncproxy nova-scheduler neutron-server neutron-plugin-ml2 neutron-linuxbridge-agent neutron-dhcp-agent neutron-metadata-agent neutron-plugin-ml2 neutron-openvswitch-agent neutron-l3-agent python3-neutronclient
apt-get -dy install nova-compute-qemu
apt-get -dy install openstack-dashboard openstack-dashboard-apache
# currently openstack-dashboard-debian-theme is not working with openstack-dashboard
# apt-get -dy install openstack-dashboard-debian-theme
echo "done"
}
function update_hostip() {
echo "updating host IP..."
sed -i "s/127.0.1.1[[:blank:]]${OPENSTACK_HOST}/#127.0.1.1 ${OPENSTACK_HOST}/" /etc/hosts
sed -i "/#127.0.1.1/a ${OPENSTACK_HOST_IP} ${OPENSTACK_HOST}" /etc/hosts
echo "done"
}
function setup_chrony() {
echo "installing chrony..."
apt-get -y install chrony
systemctl enable chrony
systemctl restart chrony
echo "done"
}
function setup_mariadb() {
echo "installing mariadb..."
apt-get -y install mariadb-server python3-pymysql
sed "s/REPLACE_WITH_OPENSTACK_HOST_IP/${OPENSTACK_HOST_IP}/" ${CONFIG_DIR}/99-openstack.cnf > /etc/mysql/mariadb.conf.d/99-openstack.cnf
systemctl restart mariadb
echo "done"
}
function setup_rabbitmq() {
echo "installing rabbitmq"
apt-get -y install rabbitmq-server
export PATH=$PATH:/usr/sbin/:/sbin
rabbitmqctl add_user openstack RABBIT_PASS
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
echo "done"
}
function setup_memcahed() {
echo "installing memcahed"
apt-get -y install memcached python3-memcache
sed -i "s/-l 127.0.0.1/-l ${OPENSTACK_HOST_IP}/" /etc/memcached.conf
systemctl enable memcached
systemctl restart memcached
echo "done"
}
function setup_etcd() {
echo "installing etcd"
apt-get -y install etcd
sed "s/REPLACE_WITH_OPENSTACK_HOST_IP/${OPENSTACK_HOST_IP}/" ${CONFIG_DIR}/etcd >> /etc/default/etcd
sed -i "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" /etc/default/etcd
systemctl enable etcd
systemctl restart etcd
echo "done"
}
function setup_database_tables() {
echo "creating database tables..."
mysql -u root < ${CONFIG_DIR}/database.sql
echo "done"
}
function setup_apache2() {
echo "installing apache2..."
apt-get -y install apache2
# set servername in apache2
sed -i "1i ServerName ${OPENSTACK_HOST}" /etc/apache2/apache2.conf
systemctl restart apache2
echo "done"
}
function setup_keystone() {
echo "installing keystone..."
apt-get -y install keystone
mv /etc/keystone/keystone.conf /etc/keystone/keystone.conf.org
systemctl stop keystone
sed "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" ${CONFIG_DIR}/keystone.conf > /etc/keystone/keystone.conf
apt-get -y install python3-openstackclient
su -s /bin/sh -c "keystone-manage db_sync" keystone
systemctl restart apache2
systemctl start keystone
echo "done"
}
function configure_keystone() {
echo "configuring keystone..."
# keystone-manage
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
keystone-manage bootstrap --bootstrap-password ADMIN_PASS --bootstrap-admin-url http://${OPENSTACK_HOST}:5000/v3/ --bootstrap-internal-url http://${OPENSTACK_HOST}:5000/v3/ --bootstrap-public-url http://${OPENSTACK_HOST}:5000/v3/ --bootstrap-region-id RegionOne
echo "done"
}
function set_auth_variables() {
echo "setting auth variables..."
sed "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" ${CONFIG_DIR}/admin-openrc > admin-openrc
sed "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" ${CONFIG_DIR}/demo-openrc > demo-openrc
source admin-openrc
echo "done"
}
function configure_domain_project() {
echo "configuring doamin and project..."
openstack domain create --description "An Example Domain" example
openstack project create --domain default --description "Service Project" service
openstack project create --domain default --description "Demo Project" myproject
openstack user create --domain default --password ${MY_USER_PASS} ${MY_USER_NAME}
openstack role create myrole
openstack role add --project myproject --user ${MY_USER_NAME} myrole
echo "done"
}
function configure_glance_endpoints() {
echo "configuring glance endpoints..."
openstack user create --domain default --password glance glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://${OPENSTACK_HOST}:9292
openstack endpoint create --region RegionOne image internal http://${OPENSTACK_HOST}:9292
openstack endpoint create --region RegionOne image admin http://${OPENSTACK_HOST}:9292
openstack user create --domain default --password MY_SERVICE MY_SERVICE
openstack role add --user MY_SERVICE --user-domain default --system all reader
echo "done"
}
function setup_glance() {
echo "installing glance..."
apt-get -y install glance
systemctl stop glance-*
mv /etc/glance/glance-api.conf /etc/glance/glance-api.conf.org
sed "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" ${CONFIG_DIR}/glance-api.conf > /etc/glance/glance-api.conf
su -s /bin/sh -c "glance-manage db_sync" glance
systemctl start glance-api
systemctl enable glance-api
#wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
#glance image-create --name "cirros" \
# --file cirros-0.4.0-x86_64-disk.img \
# --disk-format qcow2 --container-format bare \
# --visibility=public
echo "done"
}
function configure_placement_endpoints() {
echo "configuring placement endpoints..."
openstack user create --domain default --password placement placement
openstack role add --project service --user placement admin
openstack service create --name placement --description "Placement API" placement
openstack endpoint create --region RegionOne placement public http://${OPENSTACK_HOST}:8778
openstack endpoint create --region RegionOne placement internal http://${OPENSTACK_HOST}:8778
openstack endpoint create --region RegionOne placement admin http://${OPENSTACK_HOST}:8778
echo "done"
}
function setup_placement() {
echo "installing placement..."
apt-get -y install placement-api
mv /etc/placement/placement.conf /etc/placement/placement.conf.org
sed "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" ${CONFIG_DIR}/placement.conf > /etc/placement/placement.conf
su -s /bin/sh -c "placement-manage db sync" placement
systemctl restart placement-api
systemctl enable placement-api
systemctl restart apache2
echo "done"
}
function configure_nova_endpoints() {
echo "configuring nova endpoints..."
openstack user create --domain default --password nova nova
openstack role add --project service --user nova admin
openstack service create --name nova --description "OpenStack Compute" compute
openstack endpoint create --region RegionOne compute public http://${OPENSTACK_HOST}:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://${OPENSTACK_HOST}:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://${OPENSTACK_HOST}:8774/v2.1
echo "done"
}
function setup_nova() {
echo "installing nova..."
apt-get -y install libguestfs-tools virt-manager
apt-get -y install nova-api nova-conductor nova-novncproxy nova-scheduler
systemctl stop nova-*
mv /etc/nova/nova.conf /etc/nova/nova.conf.org
cp ${CONFIG_DIR}/nova.conf /etc/nova/nova.conf
sed -i "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" /etc/nova/nova.conf
sed -i "s/REPLACE_WITH_OPENSTACK_HOST_IP/${OPENSTACK_HOST_IP}/" /etc/nova/nova.conf
su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
su -s /bin/sh -c "nova-manage db sync" nova
apt-get -y install nova-compute
apt-get -y install nova-compute-qemu
systemctl start nova-api
systemctl enable nova-api
systemctl enable nova-scheduler
systemctl enable nova-conductor
systemctl enable nova-novncproxy
systemctl enable nova-serialproxy
systemctl enable nova-spicehtml5proxy
systemctl enable nova-novncproxy
systemctl enable nova-compute
# find hypervisor
su -s /bin/bash nova -c "nova-manage cell_v2 discover_hosts"
#systemctl restart nova-*
systemctl restart nova-api
systemctl restart nova-scheduler
systemctl restart nova-conductor
systemctl restart nova-novncproxy
systemctl restart nova-serialproxy
systemctl restart nova-spicehtml5proxy
systemctl restart nova-novncproxy
systemctl restart nova-compute
echo "done"
}
function configure_neutron_endpoints() {
echo "configuring neutron endpoints..."
openstack user create --domain default --password neutron neutron
openstack role add --project service --user neutron admin
openstack service create --name neutron --description "OpenStack Networking" network
openstack endpoint create --region RegionOne network public http://${OPENSTACK_HOST}:9696
openstack endpoint create --region RegionOne network internal http://${OPENSTACK_HOST}:9696
openstack endpoint create --region RegionOne network admin http://${OPENSTACK_HOST}:9696
echo "done"
}
function setup_neutron() {
echo "installing neutron..."
apt-get -y install neutron-server neutron-plugin-ml2 neutron-linuxbridge-agent neutron-dhcp-agent neutron-metadata-agent
systemctl stop neutron-*
mv /etc/neutron/neutron.conf /etc/neutron/neutron.conf.org
cp ${CONFIG_DIR}/neutron.conf /etc/neutron/neutron.conf
sed -i "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" /etc/neutron/neutron.conf
mv /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.org
cp ${CONFIG_DIR}/metadata_agent.ini /etc/neutron/metadata_agent.ini
sed -i "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" /etc/neutron/metadata_agent.ini
# update for neutron config
cp ${CONFIG_DIR}/nova2.conf /etc/nova/nova.conf
sed -i "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" /etc/nova/nova.conf
sed -i "s/REPLACE_WITH_OPENSTACK_HOST_IP/${OPENSTACK_HOST_IP}/" /etc/nova/nova.conf
mv /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.org
cp ${CONFIG_DIR}/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini
mv /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.org
sed 's/PROVIDER_INTERFACE/'$EXTERNAL_BRIDGE_INTERFACE'/' ${CONFIG_DIR}/linuxbridge_agent.ini > /etc/neutron/plugins/ml2/linuxbridge_agent.ini
mv /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.org
cp ${CONFIG_DIR}/dhcp_agent.ini /etc/neutron/dhcp_agent.ini
cp /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.org
sed -i "s/interface_driver = openvswitch/interface_driver = linuxbridge/" /etc/neutron/l3_agent.ini
systemctl enable neutron-api
systemctl enable neutron-rpc-server
systemctl enable neutron-metadata-agent
systemctl enable neutron-linuxbridge-agent
systemctl enable neutron-dhcp-agent
systemctl restart nova-*
systemctl restart neutron-api
systemctl restart neutron-rpc-server
systemctl restart neutron-metadata-agent
systemctl restart neutron-linuxbridge-agent
systemctl restart neutron-dhcp-agent
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
echo "done"
}
function enable_hypervisor() {
echo "updating hypervisor"
su -s /bin/bash nova -c "nova-manage cell_v2 discover_hosts"
echo "done"
}
function install_dashboard() {
echo "installing dashboard"
apt-get -y install openstack-dashboard-apache
mv /etc/openstack-dashboard/local_settings.py /etc/openstack-dashboard/local_settings.py.org
sed "s/REPLACE_WITH_HOST/${OPENSTACK_HOST}/" ${CONFIG_DIR}/local_settings.py > /etc/openstack-dashboard/local_settings.py
/usr/sbin/a2enmod ssl
/usr/sbin/a2enmod rewrite
systemctl restart apache2
echo "done"
}
download_packages
update_hostip
setup_chrony
setup_mariadb
setup_rabbitmq
setup_memcahed
setup_etcd
setup_database_tables
setup_apache2
setup_keystone
configure_keystone
set_auth_variables
configure_domain_project
configure_glance_endpoints
setup_glance
configure_placement_endpoints
setup_placement
configure_nova_endpoints
setup_nova
configure_neutron_endpoints
setup_neutron
enable_hypervisor
install_dashboard
|