Since VMware Integrated OpenStack is DefCore-compliant, our users can easily leverage popular community tools, such as Vagrant, to work with our distribution. In this article, we will discuss how to prepare your development environment for using Vagrant with OpenStack, and we will deploy a single instance. In our next installment, we will discuss a multi-instance deployment.
If you are not familiar with Vagrant, it is a HashiCorp solution for quickly building repeatable development according to instructions contained in a simple text file known as the Vagrantfile. The Vagrantfile specifies how you want to configure a template VM (also known as a “box”) with multiple customization options including shell scripts, Puppet manifests, Chef recipes, Ansible playbooks, etc.
For the examples below, I used the Vagrant OpenStack plugin developed by Edmund Haselwanter and the team at Cloudbau. However, there are others that you can try if you don’t like the way this plugin works.
An important prerequisite for working with the OpenStack plugin is to register a signed certificate with your VIO installation. This is due to the Vagrant plugins currently being unable to process the OS_CACERT environment variable for self-signed certificates.
Next, install Vagrant on your desktop if you have not done so already. After installing vagrant, we need to install the OpenStack plugin using the following syntax:
vagrant plugin install vagrant-openstack-plugin
We then specify a box that will be a placeholder for the images in our OpenStack cloud:
vagrant box add openstack https://github.com/cloudbau/vagrant-openstack-plugin/raw/master/dummy.box
Vagrant typically looks for boxes on your local machine. When working with an OpenStack cloud, though, we specify an image in the cloud instead of a local box as you will see and example of this in the sample Vagrantfile below. So, this placeholder box is only here to satisfy Vagrant syntax requirements.
Finally, we are ready to use Vagrant with OpenStack. Let’s create a new directory on your local desktop. Change to that directory and type the following command:
vagrant init openstack
This will generate a sample Vagrantfile definition. We will pretty much remove all the contents from that file and replace it with content similar to the following (explanations are included as comments with the “#”) prefix:
puts "\nHave you sourced your OpenStack creds today???\n" # A helpful reminder to source your OpenStack tenant's credentials file
Vagrant.configure("2") do |config|
config.vm.box = "openstack" # specify the placeholder box
config.ssh.private_key_path = "~/.ssh/id_rsa" # replace with the path to your own private key that you use with OpenStack
config.vm.provider :openstack do |os|
os.endpoint = "#{ENV['OS_AUTH_URL']}/tokens" # Get the environment variable for the authentication URL.
os.username = "#{ENV['OS_USERNAME']}" # Get the environment variable for the username.
os.tenant_name = "#{ENV['OS_TENANT_NAME']}" # Get the environment variable for the OpenStack tenant name.
os.api_key = "#{ENV['OS_PASSWORD']}" # Get the environment variable for the OpenStack password.
os.flavor = /m1.small/ # Specify either an exact string for the flavor or a regex.
os.image = /ubuntu/ # Specify either an exact string for the image or a regex.
os.keypair_name = "demo-keypair" # Replace with your keypair name. You can use nova keypair-list to get it
os.ssh_username = "ubuntu" # The username that Vagrant will use to login to the instance and customize it.
os.networks = ["demo-network"] # You can specify one or more networks enclosed in quotes and comma-separated.
os.floating_ip = :auto # Indicate a specific Floating IP or use the :auto keyword.
os.floating_ip_pool = "EXTNET" # Specify the name of your external network.
end
end
Before we proceed, make sure to load your OpenStack credentials as environment variables, and confirm this was done with a sample CLI command like nova list. Now, we are ready to use Vagrant for the first time to bring up an OpenStack instance:
vagrant up --provider=openstack
You should see some output at the command line. After the line about rsyncing files to your instance, it will be available for use by using the following command:
vagrant ssh
When you are done with the instance, you can use the following command to get rid of it:
vagrant destroy
Try Vagrant with VMware Integrated OpenStack today, and let us know how it worked out for you!
You can learn more about VMware Integrated OpenStack on the VMware Product Walkthrough site and on the VMware Integrated OpenStack product page.