2016-01-26

This article will show you how to get a full OpenStack stack running in just two commands using DevStack. DevStack is not intended to be a general OpenStack installer, but is a great option for dev/test.

Because it was made for development and testing, DevStack takes most of the decision making out of the installation process, presenting you with a default installation environment that Just Works™.

Motivation

Although DevStack does make it easier to get an OpenStack environment up and running, it is not without its pain points. In my case, I needed an environment that I could remotely deploy and tear down daily, using a cloud provider to host my installation. After spending a sizable chunk of time over the course of a few days, I realized I could cut down my redeployment times considerably with a set of scripts that could customize my installation.

With some additional tooling, I was able to build a nearly fully automated solution that has cut deployment times down and ensures a completely reproducible build by other members of my team.

Prerequisites

The DevStack installation target should be based on an Ubuntu or Debian image. If you are deploying to a cloud environment, we have included additional instructions for deploying to either DigitalOcean or AWS as the hosting provider.

Perhaps the fastest way to get a one-off deployment working quickly is to create a droplet (at least 4GB of RAM recommended) from the DigitalOcean web interface and follow the vanilla VM setup steps below. The same steps can be used to host your DevStack deployment on a different platform.

Choose your setup from the following:

Vanilla VM setup

AWS setup

DigitalOcean setup with Tugboat

No matter where you host your deployment, it is recommended that you read through vanilla VM setup so you have an idea of the changes being made to your system.

Vanilla VM setup

The DevStack documentation strongly suggests using a disposable virtual machine to host the project, as DevStack makes a considerable number of changes to its host system.

Once you download the stack_setup.sh script described below, getting up DevStack can be done in two commands:

stack_setup.sh

The stack_setup.sh script prepares the local environment for DevStack installation. You can download the script with wget: wget https://raw.githubusercontent.com/DataDog/the-monitor/master/openstack/devstack/stack_setup.sh

After downloading the script, don’t forget to make it executable with chmod +x stack_setup.sh

Before stack_setup.sh can do anything interesting, it performs some housekeeping: updating apt repositories, and installing git. This step is especially necessary for DigitalOcean users, as the default Ubuntu install does not have git and usually has an outdated package list.

Next, the script clones the Kilo release of DevStack into /usr/local/src/devstack and creates a stack user with the bundled create-stack-user.sh script from the tools directory. Creating a separate user to run DevStack is necessary, as the installation scripts will refuse to run as root.

After creating the new user, the script creates a local.conf file, used to configure your deployment. It sets up and configures OpenStack notifications so you can view OpenStack events immediately, using the popular StackTach tool or a custom listener.

Most importantly, it sets defaults for the admin, database, RabbitMQ, and Horizon passwords, as well as the service token to bootstrap Keystone. The DevStack documentation recommends pre-set passwords to simplify the installation process. If you would like to change the defaults, modify the password options in the stack_setup.sh script. The default password is: devstack.

Finally, the script changes ownership of all files in the devstack directory (and subdirectories) to the stack user.

stack.sh

The final step in deploying DevStack is running the stack.sh script as the stack user. This script handles the actual deployment of DevStack. It is highly recommended that you carefully read the script contents to better understand the changes OpenStack will make to your system. No user interaction should be needed until the script finishes.

AWS deployment

Deploying on AWS requires you to manually create an EC2 instance to host your deployment, as well as open up several ports for OpenStack to use.



The minimum instance size to host DevStack is m4.large. Although smaller instance types could host DevStack, over the course of our tests we found the network performance of smaller instance sizes to be inadequate. We also used the Ubuntu Server 14.04 LTS (HVM), SSD Volume Type image for our test deployment.

To ensure access to the outside world, assign a public IP address to your instance like in the screenshot below:


Last but not least, you must open up access to a number of ports in order for DevStack to successfully install. You could just open up your instance to all internet traffic, but configuring a security group is a good idea if you’d like to restrict outside access to your deployment.

Create a security group with the following ports open for ingress: 22, 80, 443, 3306, 5000, 5672, 5900 – 5999, 6000 – 6002, 6080 – 6082, 8000, 8003, 8080, 8386, 8773 – 8777, 9191, 9292, 9696, 35357. Refer to the OpenStack documentation for more information on OpenStack service ports.


Once launched, open up a terminal on your local machine. Use scp to copy the stack_setup.sh script to your EC2 instance: scp stack_setup.sh ubuntu@<your instance IP>:~. The previous command will upload the setup script to /home/ubuntu/setup_script.sh on your instance.

Next, ssh into your instance and run the script as root:

Once the script executes, you will have a copy of the DevStack project in /usr/local/src/devstack and a new stack user.

Then, you just need to execute stack.sh as the stack user.

The script should take ~20 minutes to execute. When it is finished, continue on to Success to get started with your new deployment.

DigitalOcean deployment with Tugboat

If you have a DigitalOcean droplet running, you can simply run the vanilla VM setup steps to install OpenStack.

If you want to automate the entire OpenStack setup, including provisioning machines, you can do that on DigitalOcean using Tugboat. If you plan on doing a lot of OpenStack testing, chances are you’ll break some things along the way. With Tugboat, you can quickly and easily deploy and tear down your stack, so you have a fresh deployment to hack on daily. The next section of this article explains how to use Tugboat to create and setup a droplet running DevStack.

Tugboat configuration

Tugboat is a handy package that allows you to manage your DigitalOcean account from the command line. We will take advantage of its powerful features to create an appropriately sized droplet to host our DevStack deployment.

Tugboat requires Ruby 1.9 or higher. Check for a compatible version with ruby -v. Once you’ve upgraded Ruby or verified your version, installation is a single command: gem install tugboat.

Tugboat needs an authentication token from DigitalOcean—you can grab yours here. You can only view your token once upon creation, so make sure you store it somewhere as you will need it in the next step.

With authentication token in hand, run tugboat authorize. You should see a series of prompts, reproduced below. You need only to enter your access token and a path to an SSH key; the defaults should suffice for the rest.

If you see “Authentication with DigitalOcean was successful!”, you’re good to go.

After authenticating, make sure to set a default SSH key. You can get a list of your SSH key IDs with tugboat keys.

For example, if you wanted to use the DO-webserver key listed in the output above, open up tugboat’s configuration file at ~/.tugboat and change the value of ssh_key to 1532126.

deploy_droplet.py

deploy_droplet.py is a Python script that creates an appropriately sized droplet on DigitalOcean to host DevStack. You need only to provide a name for your droplet, which you can supply either as a command line parameter or as input at the prompt.

You can download the script with the following command: wget https://raw.githubusercontent.com/DataDog/the-monitor/master/openstack/devstack/deploy_droplet.py

Once downloaded, make the script executable and then run deploy_droplet.py

which should produce output resembling the following:

As you can see from the above output, the script creates the droplet, returns its IP address, and lists a series of commands to execute in order on the newly created instance. Simply copy-paste the commands to set up OpenStack. If you’d like more information on the work performed in each step of the script, jump to vanilla VM setup. Otherwise, skip ahead to start using your new deployment.

Success

Wherever you chose to deploy DevStack, once setup is complete you should be greeted with output like the following:

To access statistics about your deployment, including number of instances and quota usage, navigate to the Horizon address listed in the output.

Log in as the admin user with password: devstack

Conclusion

On average, you should expect the following approximate execution times for the various steps listed in this post:

– deploy_stack.py: ~20-60 seconds

– stack_setup.sh: ~1 minute

– stack.sh: ~16-26 minutes

– Approximate total execution time: < 30 minutes

Of course, your actual installation time will vary depending on your network speed.

If you’ve been following along on your own machine, you should now have a DevStack deployment ready for use. To learn how to monitor an OpenStack deployment, check out our three-part series.

The post Install OpenStack in two commands for dev and test appeared first on Datadog.

Show more