Skip to content

Instantly share code, notes, and snippets.

@gabriel-bezerra
Last active August 29, 2015 14:00
Show Gist options
  • Save gabriel-bezerra/bb8efb595d4fd38fe286 to your computer and use it in GitHub Desktop.
Save gabriel-bezerra/bb8efb595d4fd38fe286 to your computer and use it in GitHub Desktop.
Script to deploy DevStack on an Ubuntu machine -- should be run as root
#!/bin/bash
set -ex
apt-get -yq update
apt-get -yq upgrade
cd /root
# Install DevStack
apt-get -yq install git
useradd stack -U -m -s /bin/bash -p '$6$bEWOOVRQ$WsLfGE2iYyRngHkl6ZqexUQuKbMITGGs6tg2DmxPVLVMBtjhrOfWbAlWvVr7gToH3TJx366Fvdb8IedN16AIy/'
cd /home/stack
git clone https://github.com/openstack-dev/devstack.git
cat > devstack/local.conf <<"EOF"
[[local|localrc]]
# Sample ``localrc`` for user-configurable variables in ``stack.sh``
# NOTE: Copy this file to the root ``devstack`` directory for it to
# work properly.
# ``localrc`` is a user-maintained setings file that is sourced from ``stackrc``.
# This gives it the ability to override any variables set in ``stackrc``.
# Also, most of the settings in ``stack.sh`` are written to only be set if no
# value has already been set; this lets ``localrc`` effectively override the
# default values.
# This is a collection of some of the settings we have found to be useful
# in our DevStack development environments. Additional settings are described
# in http://devstack.org/localrc.html
# These should be considered as samples and are unsupported DevStack code.
# Minimal Contents
# ----------------
# While ``stack.sh`` is happy to run without ``localrc``, devlife is better when
# there are a few minimal variables set:
# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter
# values for them by ``stack.sh`` and they will be added to ``localrc``.
ADMIN_PASSWORD=admin
MYSQL_PASSWORD=admin
RABBIT_PASSWORD=admin
SERVICE_PASSWORD=$ADMIN_PASSWORD
FIXED_RANGE=10.11.12.0/24
FIXED_NETWORK_SIZE=256
FLAT_INTERFACE=eth0
# ``HOST_IP`` should be set manually for best results if the NIC configuration
# of the host is unusual, i.e. ``eth1`` has the default route but ``eth0`` is the
# public interface. It is auto-detected in ``stack.sh`` but often is indeterminate
# on later runs due to the IP moving from an Ethernet interface to a bridge on
# the host. Setting it here also makes it available for ``openrc`` to include
# when setting ``OS_AUTH_URL``.
# ``HOST_IP`` is not set by default.
#HOST_IP=
SCREEN_LOGDIR=$DEST/logs/screen
# Logging
# -------
# By default ``stack.sh`` output only goes to the terminal where it runs. It can
# be configured to additionally log to a file by setting ``LOGFILE`` to the full
# path of the destination log file. A timestamp will be appended to the given name.
LOGFILE=$DEST/logs/stack.sh.log
# Old log files are automatically removed after 7 days to keep things neat. Change
# the number of days by setting ``LOGDAYS``.
LOGDAYS=2
# Nova logs will be colorized if ``SYSLOG`` is not set; turn this off by setting
# ``LOG_COLOR`` false.
#LOG_COLOR=False
# Using milestone-proposed branches
# ---------------------------------
# Uncomment these to grab the milestone-proposed branches from the repos:
#CINDER_BRANCH=milestone-proposed
#GLANCE_BRANCH=milestone-proposed
#HORIZON_BRANCH=milestone-proposed
#KEYSTONE_BRANCH=milestone-proposed
#KEYSTONECLIENT_BRANCH=milestone-proposed
#NOVA_BRANCH=milestone-proposed
#NOVACLIENT_BRANCH=milestone-proposed
#NEUTRON_BRANCH=milestone-proposed
#SWIFT_BRANCH=milestone-proposed
RECLONE=yes
# Swift
# -----
# Swift is now used as the back-end for the S3-like object store. If Nova's
# objectstore (``n-obj`` in ``ENABLED_SERVICES``) is enabled, it will NOT
# run if Swift is enabled. Setting the hash value is required and you will
# be prompted for it if Swift is enabled so just set it to something already:
SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
# For development purposes the default of 3 replicas is usually not required.
# Set this to 1 to save some resources:
SWIFT_REPLICAS=1
# The data for Swift is stored by default in (``$DEST/data/swift``),
# or (``$DATA_DIR/swift``) if ``DATA_DIR`` has been set, and can be
# moved by setting ``SWIFT_DATA_DIR``. The directory will be created
# if it does not exist.
SWIFT_DATA_DIR=$DEST/data
SERVICE_TOKEN=admin
EOF
HOST_IP=$(ip addr show dev eth0 | grep -e 'inet\b' | awk '{print $2}' | cut -f 1 -d/)
sed -i "s/#HOST_IP=/HOST_IP=$HOST_IP/" devstack/local.conf
chown -R stack:stack /home/stack
# Add stack to sudoers -- see http://ubuntuforums.org/showthread.php?t=1352310
if [ -e /etc/sudoers.tmp -o "$(pidof visudo)" ]; then
echo "/etc/sudoers busy"
exit 1
fi
cp /etc/sudoers /etc/sudoers.bak
cp /etc/sudoers /etc/sudoers.tmp
chmod 0640 /etc/sudoers.tmp
echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.tmp
chmod 0440 /etc/sudoers.tmp
mv -f /etc/sudoers.tmp /etc/sudoers
# Done - Add stack to sudoers
# Start DevStack
su -l stack /home/stack/devstack/stack.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment