-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdevstack.template
205 lines (175 loc) · 7.2 KB
/
devstack.template
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
heat_template_version: 2013-05-23
description: |
Creates a DevStack server.
parameters:
flavor:
description: Rackspace Cloud Server flavor
type: string
default: 4GB Standard Instance
constraints:
- allowed_values:
- 4GB Standard Instance
- 8GB Standard Instance
- 15GB Standard Instance
- 30GB Standard Instance
description: must be a valid Rackspace Cloud Server flavor large enough to run devstack
image:
type: string
description: Server image id to use
default: 5b0d5891-f80c-412a-9b73-cc996de9d719
constraints:
- allowed_values:
- 4b14a92e-84c8-4770-9245-91ecb8501cc2 # CentOS 6.5
- 5b0d5891-f80c-412a-9b73-cc996de9d719 # Ubuntu 12.04 LTS (Precise Pangolin)
- Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
description: must be a Devstack-supported distro
server_name:
description: the instance name
type: string
default: Devstack server
key_name:
description: Nova keypair name for ssh access to the server
type: string
mysql_pass:
hidden: true
description: The database admin account password
type: string
constraints:
- length:
min: 1
max: 41
description: must be between 1 and 41 characters
- allowed_pattern: "[a-zA-Z0-9]*"
description : must contain only alphanumeric characters.
admin_pass:
hidden: true
description: The database admin account password
type: string
constraints:
- length:
min: 1
max: 41
description: must be between 1 and 41 characters
- allowed_pattern: "[a-zA-Z0-9]*"
description : must contain only alphanumeric characters.
service_pass:
hidden: true
description: The service password which is used by the OpenStack services to authenticate with Keystone.
type: string
constraints:
- length:
min: 1
max: 41
description: must be between 1 and 41 characters
- allowed_pattern: "[a-zA-Z0-9]*"
description : must contain only alphanumeric characters.
rabbit_pass:
hidden: true
description: The RabbitMQ service admin password
type: string
constraints:
- length:
min: 1
max: 41
description: must be between 1 and 41 characters
- allowed_pattern: "[a-zA-Z0-9]*"
description : must contain only alphanumeric characters.
devstack_branch:
default: "master"
description: Devstack branch to clone
type: string
resources:
devstack_server:
type: OS::Nova::Server
properties:
flavor: { get_param: flavor }
image: { get_param: image }
name: { get_param: server_name }
key_name: { get_param: key_name }
user_data_format: RAW
config_drive: "true"
user_data:
str_replace:
template: |
#!/bin/bash -xv
# userdata script debug log
exec 1>/root/userdata.log 2>/root/userdata.log
# Wait until DNS resolution works
pings=0
while [[ $pings -lt 300 ]]; do
if ping -c1 mirror.rackspace.com; then
break
fi
sleep 1
((pings++))
done
# Install requirements
packages="git emacs nmap"
if apt-get update; then
apt-get install -y $packages
else
yum -y install $packages
fi
# Configure and install Devstack
groupadd stack
useradd -g stack -s /bin/bash -d /opt/stack -m stack
echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Create the devstack install script
cat >~stack/install-devstack.sh<<EOF
#!/bin/bash -x
cd ~stack
git clone git://github.com/openstack-dev/devstack.git -b "%devstack_branch%"
cd devstack
if [[ -n "%admin_pass%" ]]; then
echo "ADMIN_PASSWORD=%admin_pass%" >> localrc
fi
if [[ -n "%mysql_pass%" ]]; then
echo "MYSQL_PASSWORD=%mysql_pass%" >> localrc
fi
if [[ -n "%rabbit_pass%" ]]; then
echo "RABBIT_PASSWORD=%rabbit_pass%" >> localrc
fi
if [[ -n "%service_pass%" ]]; then
echo "SERVICE_PASSWORD=%service_pass%" >> localrc
fi
echo "SERVICE_TOKEN=$(openssl rand -hex 10)" >> localrc
echo "SWIFT_HASH=$(openssl rand -hex 10)" >> localrc
echo "ENABLED_SERVICES=c-api,c-bak,c-sch,c-vol,ceilometer-acentral,ceilometer-acompute,ceilometer-alarm-evaluator,ceilometer-alarm-notifier,ceilometer-anotification,ceilometer-api,ceilometer-collector,cinder,dstat,g-api,g-reg,h-api,h-api-cfn,h-api-cw,h-eng,heat,horizon,key,mysql,n-api,n-cond,n-cpu,n-crt,n-obj,n-sch,q-agt,q-dhcp,q-fwaas,q-l3,q-lbaas,q-meta,q-metering,q-svc,q-vpn,quantum,rabbit,s-account,s-container,s-object,s-proxy,sahara,tempest,tr-api,tr-cond,tr-tmgr,trove" >> localrc
sudo -i -u stack bash -c "~stack/devstack/stack.sh"
# Add the SSH key to the stack user
mkdir ~stack/.ssh && chmod 700 ~stack/.ssh
sudo tail -n1 /root/.ssh/authorized_keys > ~stack/.ssh/authorized_keys
chmod 400 ~stack/.ssh/authorized_keys
# Add the key to nova
nova --os-username admin --os-password "%admin_pass%" --os-tenant-name admin --os-auth-url http://localhost:5000/v2.0/ keypair-add "%key_name%" --pub-key ~stack/.ssh/authorized_keys
# Download convenience functions for Heat
curl https://raw.github.com/jasondunsmore/heat-shell/master/functions > ~stack/.bash_profile
source ~stack/.bash_profile
# Download & install prebuilt Heat JEOS images
glance_create F17-i386-cfntools http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F17-i386-cfntools.qcow2
glance_create F17-x86_64-cfntools http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F17-x86_64-cfntools.qcow2
glance_create F18-i386-cfntools http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F18-i386-cfntools.qcow2
glance_create F18-x86_64-cfntools http://fedorapeople.org/groups/heat/prebuilt-jeos-images/F18-x86_64-cfntools.qcow2
EOF
# Allow access to Horizon
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# Disable requiretty in /etc/sudoers so sudo command below will work
sed -i 's/\(Defaults.*requiretty\)/#\1/' /etc/sudoers
# Install devstack (takes ~15-20 minutes)
chmod +x ~stack/install-devstack.sh
sudo -u stack ~stack/install-devstack.sh
params:
"%mysql_pass%": { get_param: mysql_pass }
"%admin_pass%": { get_param: admin_pass }
"%rabbit_pass%": { get_param: rabbit_pass }
"%service_pass%": { get_param: service_pass }
"%key_name%": { get_param: key_name }
"%devstack_branch%": { get_param: devstack_branch }
outputs:
horizon_url:
value:
str_replace:
template: "http://%server-ip%"
params:
"%server-ip%": { get_attr: [ devstack_server, accessIPv4 ] }
description: The Horizon web control panel URL of your devstack server