Mastering OpenStack(Second Edition)
上QQ阅读APP看书,第一时间看更新

Setting up the development machine

Although OpenStack Ansible automates the complete process of setting up a dev and test OpenStack environment, it requires a machine with the correct hardware and software installed to start with. That leaves getting the development machine up and running with basic software such as the correct operating system and hardware still a manual job.

This is where tools such as Vagrant comes in handy. Vagrant helps automate the process of creating a reproducible development environment. Vagrant does this by launching virtual machines with the right operating system image. It also sets up SSH access to the virtual machine. With Vagrant, it is easy to quickly bring up a development and test environment on your laptop.

Vagrant uses VirtualBox as the default hypervisor, but can also work with other providers such as VMware and HyperV to launch virtual machines.

To start a development machine, all we need is an image for the operating system. Other hardware configuration and customization of the development machine can be described in the Vagrant configuration file. With this, Vagrant can start a development environment in a virtual machine.

Let's look at the process of creating the development machine:

  1. To start using Vagrant, we need the Vagrant installer, which can be downloaded from the Vagrant website at: https://www.vagrantup.com/downloads.html
  2. Install Vagrant on your host machine.
  3. Vagrant starts the virtual machines based on images of the operating system, which it calls boxes. So next we will find the suitable operating system image for our development machine and add it to Vagrant:
      # vagrant init ubuntu/trusty64
  1. The preceding command will download Ubuntu Trusty 14.04 for amd64 architecture and create a Vagrant file with default values. An example of the Vagrant file is shown here:
  1. Vagrant provides various other customization features through the Vagrantfile; the defaults for those configuration options are provided in the generated file.
  1. Next, we have to customize the hardware for our development machine using the Vagrantfile. Edit the Vagrantfile and add the following settings:
        config.vm.provider "virtualbox" do |v| 
v.memory = 8192
v.cpus = 8
end

The preceding settings will set up root access to the development virtual machine and set the memory and CPU requirements.

  1. Finally, you can start and log in to the development machine using the following Vagrant commands:
      # vagrant up --provider virtualbox
# vagrant ssh

With the above, you should be able to log in as a Vagrant user. Use sudo -I to become root and proceed with the next steps to create the Ansible OpenStack All-In-One development setup as described in the next section.

Due to the large disk requirement of the development environment, you will have to extend the size of the virtual machine started by Vagrant. You can always generate your own Vagrant image with a bigger disk size to fit the requirements of the development machine. The steps to create a Vagrant box are detailed at https://www.vagrantup.com/docs/virtualbox/boxes.html.