Last active
August 29, 2015 14:25
-
-
Save pratikmallya/b150ae7cb005145fd373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) | |
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 | |
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: | |
key_name: | |
type: OS::Nova::KeyPair | |
properties: | |
name: private_access_key | |
save_private_key: true | |
devstack_server: | |
type: OS::Nova::Server | |
properties: | |
flavor: { get_param: flavor } | |
image: { get_param: image } | |
name: { get_param: server_name } | |
key_name: { get_resource: 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_resource: 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 | |
private_key: | |
value: | |
get_attr: [key_name, private_key] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment