-
-
Save dscannell/5886959 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
#!/bin/bash | |
# How to use: Pass to cloud-init as user data, or run as a script. When | |
# port 80 is open, your cloud is ready. | |
set -e | |
MYIP=`ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'` | |
# Fix hosts | |
echo 127.0.0.1 $(hostname) | sudo tee -a /etc/hosts | |
# Fix MTU | |
sudo ifconfig eth0 mtu 1200 | |
# Install UCA | |
sudo apt-get -y install ubuntu-cloud-keyring | |
echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main | sudo tee /etc/apt/sources.list.d/cloud-archive.list | |
sudo apt-get update | |
sudo apt-get -y upgrade | |
# Install NTP | |
sudo apt-get -y install ntp | |
sudo tee /etc/ntp.conf <<NTPEOF | |
server ntp.ubuntu.com iburst | |
server 127.127.1.0 | |
fudge 127.127.1.0 stratum 10 | |
NTPEOF | |
sudo service ntp restart | |
# Install mysql | |
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password password' | |
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password password' | |
sudo apt-get -y install mysql-server python-mysqldb | |
mysql -u root -ppassword <<MYSQLEOF | |
CREATE DATABASE nova; | |
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'password'; | |
CREATE DATABASE cinder; | |
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'password'; | |
CREATE DATABASE glance; | |
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'password'; | |
CREATE DATABASE keystone; | |
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'password'; | |
CREATE DATABASE quantum; | |
GRANT ALL PRIVILEGES ON quantum.* TO 'quantum'@'localhost' IDENTIFIED BY 'password'; | |
FLUSH PRIVILEGES; | |
MYSQLEOF | |
# Install rabbitmq | |
sudo apt-get -y install rabbitmq-server | |
sudo rabbitmqctl change_password guest password | |
# Install keystone | |
sudo apt-get -y install keystone python-keystone python-keystoneclient | |
sudo sed -i "s;# admin_token = .*;admin_token = password;g" /etc/keystone/keystone.conf | |
sudo sed -i "s;connection = .*;connection = mysql://keystone:password@localhost:3306/keystone;g" /etc/keystone/keystone.conf | |
sudo service keystone restart | |
sudo keystone-manage db_sync | |
tee ~ubuntu/novarc <<NOVARCEOF | |
export OS_TENANT_NAME=admin | |
export OS_USERNAME=admin | |
export OS_PASSWORD=password | |
export OS_AUTH_URL="http://localhost:5000/v2.0/" | |
export SERVICE_ENDPOINT="http://localhost:35357/v2.0" | |
export SERVICE_TOKEN=password | |
NOVARCEOF | |
sudo chown ubuntu:ubuntu ~ubuntu/novarc | |
source ~ubuntu/novarc | |
echo "source novarc" >> ~ubuntu/.bashrc | |
sudo chown ubuntu:ubuntu ~ubuntu/.bashrc | |
curl -m10 --retry 100 https://raw.github.com/EmilienM/openstack-folsom-guide/master/scripts/keystone-data.sh | bash -s | |
curl -m10 --retry 100 https://raw.github.com/EmilienM/openstack-folsom-guide/master/scripts/keystone-endpoints.sh | bash -s -- -K $MYIP | |
# Install glance | |
sudo apt-get -y install glance glance-api glance-registry python-glanceclient glance-common | |
sudo sed -i "s;sql_connection = .*;sql_connection = mysql://glance:password@localhost/glance;g" /etc/glance/glance-api.conf | |
sudo sed -i "s;admin_tenant_name = .*;admin_tenant_name = service;g" /etc/glance/glance-api.conf | |
sudo sed -i "s;admin_user = .*;admin_user = glance;g" /etc/glance/glance-api.conf | |
sudo sed -i "s;admin_password = .*;admin_password = password;g" /etc/glance/glance-api.conf | |
sudo sed -i "s;notifier_strategy = .*;notifier_strategy = rabbit;g" /etc/glance/glance-api.conf | |
sudo sed -i "s;rabbit_password = .*;rabbit_password = password;g" /etc/glance/glance-api.conf | |
sudo sed -i "s;sql_connection = .*;sql_connection = mysql://glance:password@localhost/glance;g" /etc/glance/glance-registry.conf | |
sudo sed -i "s;admin_tenant_name = .*;admin_tenant_name = service;g" /etc/glance/glance-registry.conf | |
sudo sed -i "s;admin_user = .*;admin_user = glance;g" /etc/glance/glance-registry.conf | |
sudo sed -i "s;admin_password = .*;admin_password = password;g" /etc/glance/glance-registry.conf | |
sudo mv /var/lib/glance /mnt | |
sudo ln -s /mnt/glance /var/lib/glance | |
sudo service glance-api restart && sudo service glance-registry restart | |
sudo glance-manage db_sync | |
glance image-create --location http://uec-images.ubuntu.com/releases/12.04/release/ubuntu-12.04.2-server-cloudimg-amd64-disk1.img --is-public true --disk-format qcow2 --container-format bare --name "precise-cloudimg-amd64" | |
# Install nova | |
sudo apt-get -y install nova-api nova-cert nova-compute nova-compute-qemu nova-scheduler nova-network nova-volume python-nova python-novaclient nova-consoleauth novnc nova-novncproxy | |
sudo sed -i "s;admin_tenant_name = .*;admin_tenant_name = service;g" /etc/nova/api-paste.ini | |
sudo sed -i "s;admin_user = .*;admin_user = nova;g" /etc/nova/api-paste.ini | |
sudo sed -i "s;admin_password = .*;admin_password = password;g" /etc/nova/api-paste.ini | |
sudo tee /etc/nova/nova.conf <<NOVACONFEOF | |
[DEFAULT] | |
# MySQL Connection # | |
sql_connection=mysql://nova:password@localhost/nova | |
# nova-scheduler # | |
rabbit_password=password | |
scheduler_driver=nova.scheduler.simple.SimpleScheduler | |
# nova-compute # | |
connection_type=libvirt | |
libvirt_type=qemu | |
start_guests_on_host_boot=false | |
resume_guests_state_on_host_boot=false | |
# nova-api # | |
cc_host=192.168.0.1 | |
auth_strategy=keystone | |
s3_host=192.168.0.1 | |
ec2_host=192.168.0.1 | |
nova_url=http://192.168.0.1:8774/v1.1/ | |
ec2_url=http://192.168.0.1:8773/services/Cloud | |
keystone_ec2_url=http://192.168.0.1:5000/v2.0/ec2tokens | |
api_paste_config=/etc/nova/api-paste.ini | |
allow_admin_api=true | |
use_deprecated_auth=false | |
ec2_private_dns_show_ip=True | |
dmz_cidr=169.254.169.254/32 | |
ec2_dmz_host=192.168.0.1 | |
metadata_host=192.168.0.1 | |
metadata_listen=0.0.0.0 | |
enabled_apis=ec2,osapi_compute,metadata | |
# nova-network # | |
dhcpbridge_flagfile=/etc/nova/nova.conf | |
dhcpbridge=/usr/bin/nova-dhcpbridge | |
force_dhcp_release=True | |
libvirt_use_virtio_for_bridges=True | |
network_manager=nova.network.manager.FlatDHCPManager | |
flat_interface=eth0 | |
# Volumes # | |
volumes_path=/var/lib/nova/volumes | |
iscsi_helper=tgtadm | |
# Glance # | |
glance_api_servers=192.168.0.1:9292 | |
image_service=nova.image.glance.GlanceImageService | |
# novnc # | |
novnc_enable=true | |
novncproxy_base_url=http://192.168.0.1:6080/vnc_auto.html | |
vncserver_proxyclient_address=192.168.0.1 | |
vncserver_listen=0.0.0.0 | |
# Misc # | |
logdir=/var/log/nova | |
state_path=/var/lib/nova | |
lock_path=/var/lock/nova | |
root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf | |
verbose=true | |
NOVACONFEOF | |
sudo sed -i "s;192.168.0.1;$MYIP;g" /etc/nova/nova.conf | |
sudo nova-manage db sync | |
# Set up volumes | |
sudo mkdir -p /mnt/volumes/ | |
sudo dd if=/dev/zero of=/mnt/volumes/volumepv bs=1 count=1 seek=$((30*1000*1000*1000-1)) | |
sudo losetup /dev/loop0 /mnt/volumes/volumepv | |
sudo pvcreate /dev/loop0 | |
sudo vgcreate nova-volumes /dev/loop0 | |
echo losetup /dev/loop0 /mnt/volumes/volumepv | sudo tee /etc/rc.local | |
echo vgscan | sudo tee -a /etc/rc.local | |
echo service nova-volume restart | sudo tee -a /etc/rc.local | |
# Networks | |
sudo nova-manage network create private --fixed_range_v4=10.254.254.0/24 --num_networks=1 --bridge=br100 --multi_host=T | |
sudo iptables -A POSTROUTING -t nat --src 10.254.254.0/24 -j MASQUERADE | |
echo iptables -A POSTROUTING -t nat --src 10.254.254.0/24 -j MASQUERADE | sudo tee -a /etc/rc.local | |
# Compute | |
sudo mv /var/lib/nova/instances /mnt | |
sudo ln -s /mnt/instances /var/lib/nova | |
# restart services | |
for i in api cert compute consoleauth scheduler novncproxy network volume ; do sudo service nova-$i restart; done | |
# Install the dashboard | |
sudo apt-get -y install apache2 libapache2-mod-wsgi openstack-dashboard memcached python-memcache | |
# Set up secgroups | |
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 | |
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 | |
# Set up a key | |
ssh-keygen -t dsa -f ~ubuntu/.ssh/id_dsa -N '' | |
sudo chown ubuntu:ubuntu ~ubuntu/.ssh/id_dsa | |
sudo chown ubuntu:ubuntu ~ubuntu/.ssh/id_dsa.pub | |
nova keypair-add --pub-key ~ubuntu/.ssh/id_dsa.pub default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment