-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdevstack.cloudscript
More file actions
214 lines (169 loc) · 6.92 KB
/
devstack.cloudscript
File metadata and controls
214 lines (169 loc) · 6.92 KB
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
# Install latest OpenStack DevStack on a CS4.4-SSD Cloudlet ($.06/hr) running Linux Ubuntu Server 14.04 LTS 64-bit
cloudscript devstack
version = _latest
result_template = devstack_result_template
globals
devstack_hostname = 'devstack'
devstack_instance_type = 'CS4.4-SSD' # 4GB RAM, 4 vCore, 100GB SSD, 10Gbps
devstack_image_type = 'Ubuntu Server 14.04 LTS'
default_slice_user = 'devstack'
devstack_branch = 'stable/kilo'
oneforall_password = lib::random_password()
server_password = lib::random_password()
console_password = lib::random_password()
thread devstack_setup
tasks = [devstack_server_setup]
task devstack_server_setup
#----------------------
# Create devstack keys
#----------------------
# Create devstack all-for-one password key
/key/password devstack_oneforall_password_key read_or_create
key_group = _SERVER
password = oneforall_password
# Create devstack server root password key
/key/password devstack_server_password_key read_or_create
key_group = _SERVER
password = server_password
# Create devstack server console key
/key/password devstack_server_console_key read_or_create
key_group = _CONSOLE
password = console_password
#--------------------------------
# Create devstack storage slice,
# bootstrap script and recipe
#--------------------------------
# Create storage slice keys
/key/token default_slice_key read_or_create
username = default_slice_user
# Create slice to store script in cloudstorage
/storage/slice default_slice read_or_create
keys = [default_slice_key]
# Create slice container to store script in cloudstorage
/storage/container devstack_container => [default_slice] read_or_create
slice = default_slice
# Place script data in cloudstorage
/storage/object devstack_bootstrap_object => [default_slice, devstack_container] read_or_create
container_name = 'devstack_container'
file_name = 'bootstrap_devstack.sh'
slice = default_slice
content_data = devstack_bootstrap_data
# Associate the cloudstorage object with the devstack script
/orchestration/script devstack_bootstrap_script => [default_slice, devstack_container, devstack_bootstrap_object] read_or_create
data_uri = 'cloudstorage://default_slice/devstack_container/bootstrap_devstack.sh'
script_type = _SHELL
encoding = _STORAGE
# Create the recipe and associate the script
/orchestration/recipe devstack_bootstrap_recipe read_or_create
scripts = [devstack_bootstrap_script]
#
# Create the devstack server
#
/server/cloud devstack_server read_or_create
hostname = '{{ devstack_hostname }}'
image = '{{ devstack_image_type }}'
service_type = '{{ devstack_instance_type }}'
keys = [devstack_server_password_key, devstack_server_console_key]
recipes = [devstack_bootstrap_recipe]
recipe_timeout = 660
text_template devstack_bootstrap_data
#!/bin/sh
# check if running as root
[ `whoami` = 'root' ] || {
echo "ERROR: must have root permissions to execute the commands"
exit 1
}
# Update packages
apt-get update
#apt-get upgrade -y
# Install git
apt-get install git -y
# Clone devstack repo from stable branch
cd /opt
git clone -b stable/kilo https://github.com/openstack-dev/devstack.git
# enabling SNAT and IP masquerade
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# creating the file for fetching inet address amd executing commands
cat << \EOF >/opt/devstack/dnsconf
#!/bin/bash
cd /opt/devstack/
source /opt/devstack/openrc admin demo
/usr/local/bin/neutron subnet-list | awk '{print $2}' > id.txt
i1=`sed '4!d' id.txt`
i2=`sed '5!d' id.txt`
/usr/local/bin/neutron subnet-update $i1 --dns-nameservers list=true 8.8.8.8 8.8.4.4
/usr/local/bin/neutron subnet-update $i2 --dns-nameservers list=true 8.8.8.8 8.8.4.4
EOF
# Create local.conf with necessary config options
cat << \EOF >/opt/devstack/local.conf
[[local|localrc]]
#Network
#HOST_IP=
HOST_IP_IFACE=eth0
# Database user
DATABASE_USER=root
# Passwords
DATABASE_PASSWORD={{ devstack_oneforall_password_key.password }}
ADMIN_PASSWORD={{ devstack_oneforall_password_key.password }}
SERVICE_PASSWORD={{ devstack_oneforall_password_key.password }}
SERVICE_TOKEN={{ devstack_oneforall_password_key.password }}
RABBIT_PASSWORD=guest
SWIFT_HASH={{ devstack_oneforall_password_key.password }}
# Branches
# Modified the branch after the KILO version released
KEYSTONE_BRANCH=stable/kilo
NOVA_BRANCH=stable/kilo
NEUTRON_BRANCH=stable/kilo
SWIFT_BRANCH=stable/kilo
GLANCE_BRANCH=stable/kilo
CINDER_BRANCH=stable/kilo
HEAT_BRANCH=stable/kilo
TROVE_BRANCH=stable/kilo
HORIZON_BRANCH=stable/kilo
# Services
ENABLED_SERVICES=rabbit,mysql,key
ENABLED_SERVICES+=,n-api,n-crt,n-obj,n-cpu,n-cond,n-sch,n-novnc,n-cauth
ENABLED_SERVICES+=,neutron,q-svc,q-agt,q-dhcp,q-l3,q-meta,q-lbaas
#ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account
ENABLED_SERVICES+=,g-api,g-reg
ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch,c-bak
ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
ENABLED_SERVICES+=,trove,tr-api,tr-tmgr,tr-cond
ENABLED_SERVICES+=,horizon
# Enable Logging
LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=True
SCREEN_LOGDIR=/opt/stack/logs
EOF
# Add public IP to configuration
IP=`ifconfig eth0 | grep "inet addr" | head -n 1 | cut -d : -f 2 | cut -d " " -f 1`
sed -r "s/#HOST_IP=/HOST_IP=$IP/g" /opt/devstack/local.conf > /opt/devstack/local.conf.tmp
mv /opt/devstack/local.conf.tmp /opt/devstack/local.conf
# Replace passwords with hash
HASH=`echo "{{ devstack_oneforall_password_key.password }}" | sha256sum |awk '{print $1}'`
sed -r "s/SWIFT_HASH=.*/SWIFT_HASH=$HASH/g" /opt/devstack/local.conf > /opt/devstack/local.conf.tmp
mv /opt/devstack/local.conf.tmp /opt/devstack/local.conf
# Create user
/opt/devstack/tools/create-stack-user.sh
# Change privileges
chown -R stack:stack /opt/devstack
# change directory to execute stack.sh
cd /opt/devstack
# Create stack
su stack -c /opt/devstack/stack.sh
# Changing the permission of file
chmod -R 755 /opt/devstack/dnsconf
# execute the file for allowing DNS access from openstack instance
/opt/devstack/dnsconf
_eof
text_template devstack_result_template
Horizon will be ready in few minutes at http://{{ devstack_server.ipaddress_public }}/
Login: admin
Password: {{ devstack_oneforall_password_key.password }}
You can login via ssh to: {{ devstack_server.ipaddress_public }}
Login: root
Password: {{ devstack_server_password_key.password }}
_eof