-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathall-in-one.sh
359 lines (260 loc) · 13.9 KB
/
all-in-one.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
#################### Mastering OpenStack Controller Install ####################
# MySQL install preparation
export DEBIAN_FRONTEND=noninteractive
export MYSQL_ROOT_PASS=openstack
export MYSQL_HOST=0.0.0.0
export MYSQL_PASS=openstack
echo "mysql-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASS" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASS" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password seen true" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again seen true" | sudo debconf-set-selections
sudo apt-get update
sudo apt-get install -y ubuntu-cloud-keyring vim git ntp openssh-server curl
sudo echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/havana main" | sudo tee /etc/apt/sources.list.d/havana.list
sudo apt-get install python-software-properties -y
sudo apt-get update && apt-get upgrade -y
# Install NTP while we are here
echo "ntpdate aio-havana
hwclock -w" | sudo tee /etc/cron.daily/ntpdate
chmod a+x /etc/cron.daily/ntpdate
sudo apt-get -y install mysql-server python-mysqldb rabbitmq-server
sudo sed -i "s/^bind\-address.*/bind-address = ${MYSQL_HOST}/g" /etc/mysql/my.cnf
# Skip Name Resolve
echo "[mysqld]
skip-name-resolve" > /etc/mysql/conf.d/skip-name-resolve.cnf
sudo restart mysql
#################### Keystone Install ####################
# Keystone install and configuration
sudo apt-get -y install keystone python-keystone python-keystoneclient
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "CREATE DATABASE keystone;"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY '$MYSQL_PASS';"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON keystone.* TO 'keystone'@'%' IDENTIFIED BY '$MYSQL_PASS';"
# Configure the Keystone for our MySQL database
sudo sed -i 's#^connection.*#connection = mysql://keystone:openstack@127.0.0.1/keystone#' /etc/keystone/keystone.conf
sudo sed -i 's/^# admin_token.*/admin_token = ADMIN/' /etc/keystone/keystone.conf
# Restart the Keystone services
sudo stop keystone
sudo start keystone
sudo keystone-manage db_sync
sudo apt-get -y install python-keystoneclient
export CONTROLLER_HOST=${INTERNAL_IP}
export KEYSTONE_ENDPOINT=${INTERNAL_IP}
export GLANCE_HOST=${CONTROLLER_HOST}
export MYSQL_HOST=${CONTROLLER_HOST}
export KEYSTONE_ENDPOINT=${CONTROLLER_HOST}
export SERVICE_TENANT_NAME=service
export SERVICE_PASS=openstack
export ENDPOINT=${KEYSTONE_ENDPOINT}
export SERVICE_TOKEN=ADMIN
export SERVICE_ENDPOINT=http://${ENDPOINT}:35357/v2.0
export OS_AUTH_URL="http://${KEYSTONE_ENDPOINT}:5000/v2.0/"
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=openstack
#################### Create our roles, tenants and users ####################
# admin role
keystone role-create --name admin
# Member role
keystone role-create --name Member
keystone tenant-create --name admin --description "Default OpenStack Tenant" --enabled true
TENANT_ID=$(keystone tenant-list | awk '/\ admin\ / {print $2}')
export PASSWORD=openstack
keystone user-create --name admin --tenant_id $TENANT_ID --pass $PASSWORD --email root@localhost --enabled true
TENANT_ID=$(keystone tenant-list | awk '/\ admin\ / {print $2}')
ROLE_ID=$(keystone role-list | awk '/\ admin\ / {print $2}')
USER_ID=$(keystone user-list | awk '/\ admin\ / {print $2}')
keystone user-role-add --user $USER_ID --role $ROLE_ID --tenant_id $TENANT_ID
# Create the user
PASSWORD=openstack
keystone user-create --name demo --tenant_id $TENANT_ID --pass $PASSWORD --email demo@localhost --enabled true
TENANT_ID=$(keystone tenant-list | awk '/\ admin\ / {print $2}')
ROLE_ID=$(keystone role-list | awk '/\ Member\ / {print $2}')
USER_ID=$(keystone user-list | awk '/\ demo\ / {print $2}')
# Assign the Member role to the demo user in admin
keystone user-role-add --user $USER_ID --role $ROLE_ID --tenant_id $TENANT_ID
# OpenStack Compute Nova API Endpoint
keystone service-create --name nova --type compute --description 'OpenStack Compute Service'
# OpenStack Compute EC2 API Endpoint
keystone service-create --name ec2 --type ec2 --description 'EC2 Service'
# Glance Image Service Endpoint
keystone service-create --name glance --type image --description 'OpenStack Image Service'
# Keystone Identity Service Endpoint
keystone service-create --name keystone --type identity --description 'OpenStack Identity Service'
# Cinder Block Storage Endpoint
## keystone service-create --name volume --type volume --description 'Volume Service'
# OpenStack Compute Nova API
NOVA_SERVICE_ID=$(keystone service-list | awk '/\ nova\ / {print $2}')
PUBLIC="http://$ENDPOINT:8774/v2/\$(tenant_id)s"
ADMIN=$PUBLIC
INTERNAL=$PUBLIC
keystone endpoint-create --region RegionOne --service_id $NOVA_SERVICE_ID --publicurl $PUBLIC --adminurl $ADMIN --internalurl $INTERNAL
# OpenStack Compute EC2 API
EC2_SERVICE_ID=$(keystone service-list | awk '/\ ec2\ / {print $2}')
PUBLIC="http://$ENDPOINT:8773/services/Cloud"
ADMIN="http://$ENDPOINT:8773/services/Admin"
INTERNAL=$PUBLIC
keystone endpoint-create --region RegionOne --service_id $EC2_SERVICE_ID --publicurl $PUBLIC --adminurl $ADMIN --internalurl $INTERNAL
# Glance Image Service
GLANCE_SERVICE_ID=$(keystone service-list | awk '/\ glance\ / {print $2}')
PUBLIC="http://$ENDPOINT:9292/v1"
ADMIN=$PUBLIC
INTERNAL=$PUBLIC
keystone endpoint-create --region RegionOne --service_id $GLANCE_SERVICE_ID --publicurl $PUBLIC --adminurl $ADMIN --internalurl $INTERNAL
# Keystone OpenStack Identity Service
KEYSTONE_SERVICE_ID=$(keystone service-list | awk '/\ keystone\ / {print $2}')
PUBLIC="http://$ENDPOINT:5000/v2.0"
ADMIN="http://$ENDPOINT:35357/v2.0"
INTERNAL=$PUBLIC
keystone endpoint-create --region RegionOne --service_id $KEYSTONE_SERVICE_ID --publicurl $PUBLIC --adminurl $ADMIN --internalurl $INTERNAL
# Cinder Block Storage Service
CINDER_SERVICE_ID=$(keystone service-list | awk '/\ volume\ / {print $2}')
PUBLIC="http://$ENDPOINT:8776/v1/%(tenant_id)s"
ADMIN=$PUBLIC
INTERNAL=$PUBLIC
### keystone endpoint-create --region RegionOne --service_id $CINDER_SERVICE_ID --publicurl $PUBLIC --adminurl $ADMIN --internalurl $INTERNAL
# Service Tenant
keystone tenant-create --name service --description "Service Tenant" --enabled true
SERVICE_TENANT_ID=$(keystone tenant-list | awk '/\ service\ / {print $2}')
keystone user-create --name nova --pass nova --tenant_id $SERVICE_TENANT_ID --email nova@localhost --enabled true
keystone user-create --name glance --pass glance --tenant_id $SERVICE_TENANT_ID --email glance@localhost --enabled true
keystone user-create --name keystone --pass keystone --tenant_id $SERVICE_TENANT_ID --email keystone@localhost --enabled true
### keystone user-create --name cinder --pass cinder --tenant_id $SERVICE_TENANT_ID --email cinder@localhost --enabled true
# Get the nova user id
NOVA_USER_ID=$(keystone user-list | awk '/\ nova\ / {print $2}')
# Get the admin role id
ADMIN_ROLE_ID=$(keystone role-list | awk '/\ admin\ / {print $2}')
# Assign the nova user the admin role in service tenant
keystone user-role-add --user $NOVA_USER_ID --role $ADMIN_ROLE_ID --tenant_id $SERVICE_TENANT_ID
# Get the glance user id
GLANCE_USER_ID=$(keystone user-list | awk '/\ glance\ / {print $2}')
# Assign the glance user the admin role in service tenant
keystone user-role-add --user $GLANCE_USER_ID --role $ADMIN_ROLE_ID --tenant_id $SERVICE_TENANT_ID
# Get the keystone user id
KEYSTONE_USER_ID=$(keystone user-list | awk '/\ keystone\ / {print $2}')
# Assign the keystone user the admin role in service tenant
keystone user-role-add --user $KEYSTONE_USER_ID --role $ADMIN_ROLE_ID --tenant_id $SERVICE_TENANT_ID
# Get the cinder user id
### CINDER_USER_ID=$(keystone user-list | awk '/\ cinder \ / {print $2}')
# Assign the cinder user the admin role in service tenant
### keystone user-role-add --user $CINDER_USER_ID --role $ADMIN_ROLE_ID --tenant_id $SERVICE_TENANT_ID
echo "export CONTROLLER_HOST=${INTERNAL_IP}
export KEYSTONE_ENDPOINT=${INTERNAL_IP}
export GLANCE_HOST=${CONTROLLER_HOST}
export MYSQL_HOST=${CONTROLLER_HOST}
export KEYSTONE_ENDPOINT=${CONTROLLER_HOST}
export SERVICE_TENANT_NAME=service
export SERVICE_PASS=openstack
export ENDPOINT=${KEYSTONE_ENDPOINT}
export SERVICE_TOKEN=ADMIN
export SERVICE_ENDPOINT=http://${ENDPOINT}:35357/v2.0
export OS_AUTH_URL="http://${KEYSTONE_ENDPOINT}:5000/v2.0/"
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=openstack" | sudo tee /root/openrc
source /root/openrc
echo "source /root/openrc" >> ~/.bashrc
#################### Glance Install ####################
sudo apt-get install -y glance glance-api glance-registry python-glanceclient glance-common
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "CREATE DATABASE glance;"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '$MYSQL_PASS';"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON glance.* TO 'glance'@'%' IDENTIFIED BY '$MYSQL_PASS';"
sudo sed -i 's#^sql_connection.*#sql_connection = mysql://glance:openstack@127.0.0.1/glance#' /etc/glance/glance-registry.conf
sudo sed -i 's#^auth_host.*#auth_host = aio-havana#' /etc/glance/glance-registry.conf
sudo sed -i 's#^admin_tenant_name.*#admin_tenant_name = service#' /etc/glance/glance-registry.conf
sudo sed -i 's#^admin_user.*#admin_user = glance#' /etc/glance/glance-registry.conf
sudo sed -i 's#^admin_password.*#admin_password = glance#' /etc/glance/glance-registry.conf
sudo sed -i 's#^sql_connection.*#sql_connection = mysql://glance:openstack@127.0.0.1/glance#' /etc/glance/glance-api.conf
sudo sed -i 's#^auth_host.*#auth_host = aio-havana#' /etc/glance/glance-api.conf
sudo sed -i 's#^admin_tenant_name.*#admin_tenant_name = service#' /etc/glance/glance-api.conf
sudo sed -i 's#^admin_user.*#admin_user = glance#' /etc/glance/glance-api.conf
sudo sed -i 's#^admin_password.*#admin_password = glance#' /etc/glance/glance-api.conf
sudo sed -i '/^\[filter:authtoken\]/d' /etc/glance/glance-api-paste.ini
sudo sed -i '/^delay_auth_decision.*/d' /etc/glance/glance-api-paste.ini
sudo sed -i '/^paste.filter_factory = keystoneclient.middleware.auth_token.*/d' /etc/glance/glance-api-paste.ini
echo "auth_host = aio-havana
admin_user = glance
admin_tenant_name = service
admin_password = glance
" | sudo tee -a /etc/glance/glance-registry-paste.ini
echo "
[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
auth_host = aio-havana
admin_user = glance
admin_tenant_name = service
admin_password = glance
" | sudo tee -a /etc/glance/glance-api-paste.ini
service glance-api restart && service glance-registry restart
glance-manage db_sync
wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img
glance image-create --is-public true --disk-format qcow2 --container-format bare --name "Cirros 0.3.1" < cirros-0.3.1-x86_64-disk.img
#################### Nova Install ####################
apt-get install -y nova-novncproxy novnc nova-api nova-ajax-console-proxy nova-cert nova-conductor nova-consoleauth nova-doc nova-scheduler python-novaclient
sudo apt-get install -y nova-compute-kvm python-novaclient python-guestfs python-keystoneclient
sudo update-guestfs-appliance
sudo apt-get install -y nova-network
sudo chmod 0644 /boot/vmlinuz*
sudo rm /var/lib/nova/nova.sqlite
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "CREATE DATABASE nova;"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '$MYSQL_PASS';"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON nova.* TO 'nova'@'%' IDENTIFIED BY '$MYSQL_PASS';"
sudo sed -i 's#^auth_host.*#auth_host = aio-havana#' /etc/nova/api-paste.ini
sudo sed -i 's#^admin_tenant_name.*#admin_tenant_name = service#' /etc/nova/api-paste.ini
sudo sed -i 's#^admin_user.*#admin_user = nova#' /etc/nova/api-paste.ini
sudo sed -i 's#^admin_password.*#admin_password = nova#' /etc/nova/api-paste.ini
nova-manage db sync
echo "
my_ip=${INTERNAL_IP}
vncserver_listen=${INTERNAL_IP}
vncserver_proxyclient_address=${INTERNAL_IP}
auth_strategy=keystone
rpc_backend=nova.rpc.impl_kombu
rabbit_host=aio-havana
glance_host=aio-havana
network_manager=nova.network.manager.FlatDHCPManager
firewall_driver=nova.virt.libvirt.firewall.IptablesFirewallDriver
network_size=254
allow_same_net_traffic=False
multi_host=True
send_arp_for_ha=True
share_dhcp_address=True
force_dhcp_release=True
flat_network_bridge=br100
flat_interface=eth1
public_interface=eth0
novncproxy_base_url=http://${INTERNAL_IP}:6080/vnc_auto.html
[database]
mysql://nova:openstack@127.0.0.1/nova
" >> /etc/nova/nova.conf
service nova-api restart
service nova-cert restart
service nova-consoleauth restart
service nova-scheduler restart
service nova-conductor restart
service nova-novncproxy restart
#################### Horizon Install ####################
apt-get install -y memcached libapache2-mod-wsgi openstack-dashboard
apt-get remove -y --purge openstack-dashboard-ubuntu-theme
sudo sed -i "s/^\-l 127.0.0.1.*/-l ${INTERNAL_IP}/g" /etc/memcached.conf
sudo sed -i "s/^OPENSTACK_HOST.*/OPENSTACK_HOST = \"aio-havana\"/g" /etc/openstack-dashboard/local_settings.py
sudo sed -i "s/127.0.0.1/${INTERNAL_IP}/g" /etc/openstack-dashboard/local_settings.py
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "CREATE DATABASE dash;"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON dash.* TO 'dash'@'localhost' IDENTIFIED BY '$MYSQL_PASS';"
mysql -h localhost -uroot -p$MYSQL_ROOT_PASS -e "GRANT ALL ON dash.* TO 'dash'@'%' IDENTIFIED BY '$MYSQL_PASS';"
# echo "
# SESSION_ENGINE = 'django.core.cache.backends.db.DatabaseCache'
# DATABASE = {
# 'default': {
# # Database configuration here
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'dash',
# 'USER': 'dash',
# 'PASSWORD': 'openstack',
# 'HOST': 'localhost',
# 'default-character-set': 'utf8'
# }
# }
# " >> /etc/openstack-dashboard/local_settings.py
sudo . /etc/init.d/apache2 reload
#### ALL DONE ####
sudo reboot