Finalize multi-instance Vagrant and OpenStack environment

Update README.md with final information. Add comments to Vagrantfile
for better understanding and troubleshooting. Sanitize all files.
This commit is contained in:
Scott Lowe 2015-10-08 09:02:41 -06:00
parent 028bc1bd4b
commit 2f852dabb8
5 changed files with 32 additions and 28 deletions

View file

@ -10,14 +10,20 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co
* **README.md**: The file you're currently reading.
* **Vagrantfile**: This file is used by Vagrant to spin up the OpenStack instance.
* **Vagrantfile**: This file is used by Vagrant to spin up the OpenStack instance. You **must** edit this file to specify the correct URL for use with your OpenStack installation.
## Instructions
Please note that you'll need a working OpenStack installation in order to use these files.
1. Edit `credentials.yml` to supply a valid username, password, and tenant name for your particular OpenStack installation.
2. Edit `instances.yml`. The fields in this YAML file is fairly straightforward, but here's a quick breakdown:
2. Edit `Vagrantfile` and look for comments stating "Edit the following line with your correct information". There are **three** changes you must make in the `Vagrantfile`:
* You must set the correct URL for use with your OpenStack installation (see line 21 of `Vagrantfile`).
* You must set the correct path and filename for the SSH private key to use with the OpenStack instances (see line 31 of `Vagrantfile`)
* You must verify the names of the security groups specified for use with the OpenStack instances (see line 46 of `Vagrantfile`).
3. Edit `instances.yml`. The fields in this YAML file is fairly straightforward, but here's a quick breakdown:
* A display name for the instance ("name")
* The name of an OpenStack flavor ("flavor"), which you can obtain using `nova flavor-list`
* The name of an OpenStack image ("image"), obtainable via the `glance image-list` command
@ -25,16 +31,11 @@ Please note that you'll need a working OpenStack installation in order to use th
* The name of the tenant network to which the new instance should be attached ("networks")
* The SSH keypair that OpenStack should inject into the instance ("keypair")
* The username Vagrant can use to log into the instance ("ssh_user"); this will vary from image to image
3. Edit `Vagrantfile` and look for comments stating "Edit the following line with your correct information". There are **three** changes you must make in the `Vagrantfile`:
* You must specify the correct URL for authenticating with OpenStack
* You must provide the correct path for the private key that matches the keypair specified in `instances.yml`
* You must supply the list of security groups that OpenStack should apply to the new instance
4. Ensure that the system running Vagrant has connectivity to the authentication URL for OpenStack.
5. Run `vagrant up` to have Vagrant authenticate to OpenStack and create the desired instance for you. Once the instance is created, you can use `vagrant ssh` to connect to the instance, and `vagrant destroy` will terminate (destroy) the OpenStack instance for you.
4. If you wish to spin up additional instances, add stanzas to the `instances.yml` file, making sure to observe the correct YAML syntax.
5. Ensure that the system running Vagrant has connectivity to the authentication URL for OpenStack.
6. Run `vagrant up` to have Vagrant authenticate to OpenStack and create the desired instance for you. Once the instance is created, you can use `vagrant ssh` to connect to the instance, and `vagrant destroy` will terminate (destroy) the OpenStack instance for you.
Enjoy!
## Planned Enhancements
* Changing the `Vagrantfile` to allow for multi-instance configurations
* Removing all user-specific parameters from the `Vagrantfile` so that no edits are required

View file

@ -7,16 +7,18 @@ require 'yaml'
# Read YAML file with OpenStack credentials
creds = YAML.load_file('credentials.yml')
# Read YAML file with instance information
instances = YAML.load_file('instances.yml')
# Specify Vagrant version and Vagrant API version
# Specify Vagrant version, Vagrant API version, and Vagrant provider
Vagrant.require_version '>= 1.6.0'
VAGRANTFILE_API_VERSION = '2'
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'openstack'
# Specify OpenStack authentication URL
# Edit the following line with your correct information
ENV['OS_AUTH_URL'] = 'http://cloud.lowehome.net:5000/v2.0'
ENV['OS_AUTH_URL'] = 'http://controller:5000/v2.0'
# Create and configure the OpenStack instance(s)
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@ -25,7 +27,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# config.vm.box = "dummy"
# Specify path to SSH private key
config.ssh.private_key_path = '~/.ssh/homelab.pem'
# Edit the following line with your correct information
config.ssh.private_key_path = '~/.ssh/keypair.pem'
# Configure the base information for the OpenStack provider
config.vm.provider 'openstack' do |os|
@ -39,6 +42,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
os.floating_ip_pool = 'default'
os.networks = 'default'
os.keypair_name = 'default'
# Edit the following line with your correct information
os.security_groups = ['default']
os.sync_method = 'none'
end # config.vm.provider 'openstack'

View file

@ -1,4 +1,4 @@
---
username: "slowe"
password: "Me3twet8ein"
tenant: "lab"
username: "demo"
password: "demo"
tenant: "demo"

View file

@ -2,14 +2,14 @@
- name: "test-01"
flavor: "m1.small"
image: "Ubuntu 14.04.3 LTS x64"
ip_pool: "ext-net-1"
networks: "test-01"
ip_pool: "public"
networks: "test"
keypair: "homelab"
ssh_user: "ubuntu"
- name: "test-02"
flavor: "m1.small"
image: "Ubuntu 12.04.5 LTS x64"
ip_pool: "ext-net-1"
networks: "test-01"
ip_pool: "public"
networks: "test"
keypair: "homelab"
ssh_user: "ubuntu"

View file

@ -1,6 +1,6 @@
# Using Vagrant with OpenStack
# Using Vagrant with OpenStack (Single Instance)
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) to automate the provisioning and de-provisioning of OpenStack instances. This configuration was tested using Vagrant 1.7.4, version 0.7.0 of [the vagrant-openstack-provider plugin](https://github.com/ggiamarchi/vagrant-openstack-provider), and OpenStack "Juno".
These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) with OpenStack, where the VMs managed by Vagrant are actually instances in an OpenStack cloud. Using these files, Vagrant can only operate against a single instance at a time. This configuration was tested using Vagrant 1.7.4, version 0.7.0 of [the vagrant-openstack-provider plugin](https://github.com/ggiamarchi/vagrant-openstack-provider), and OpenStack "Juno".
## Contents
@ -34,7 +34,6 @@ Note that you'll need a working OpenStack installation in order to use these fil
Enjoy!
## Planned Enhancements
## Additional Notes
* Changing the `Vagrantfile` to allow for multi-instance configurations
* Removing all user-specific parameters from the `Vagrantfile` so that no edits are required
This environment will only create a single instance on OpenStack using Vagrant. If you wish to use Vagrant to create/manage multiple instances, please see the "vagrant-openstack-multi" directory in this repository instead.