diff --git a/.gitignore b/.gitignore index bfd9b8c8..e6af6d99 100755 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,7 @@ astara/test/functional/test.conf.sample #macos hidden files .DS_Store ._.DS_Store + +# Vagrant +vagrant/.vagrant +vagrant/user_local.conf diff --git a/devstack/local.conf.sample b/devstack/local.conf.sample new file mode 100644 index 00000000..d1b6cc74 --- /dev/null +++ b/devstack/local.conf.sample @@ -0,0 +1,27 @@ +# +# Sample DevStack local.conf. +# +# This sample file is intended to be used for your typical DevStack environment +# that's running all of OpenStack on a single host. This can also be used as +# the first host of a multi-host test environment. +# +# No changes to this sample configuration are required for this to work. +# + +[[local|localrc]] +enable_plugin astara https://github.com/openstack/astara +enable_service q-svc q-agt astara +disable_service n-net + +# Build the Astara appliance +#BUILD_ASTARA_APPLIANCE_IMAGE=True +#ASTARA_APPLIANCE_REPO=http://github.com/openstack/astara-appliance.git +#ASTARA_APPLIANCE_BRANCH=master + +HOST_IP=127.0.0.1 +LOGFILE=/opt/stack/logs/devstack.log +DATABASE_PASSWORD=secret +RABBIT_PASSWORD=secret +SERVICE_TOKEN=secret +SERVICE_PASSWORD=secret +ADMIN_PASSWORD=secret diff --git a/vagrant/README.md b/vagrant/README.md new file mode 100644 index 00000000..408fab24 --- /dev/null +++ b/vagrant/README.md @@ -0,0 +1,60 @@ +vagrant-devstack-astara +======================= + +Getting started +--------------- + +A Vagrant based astara. + +Steps to try vagrant image: + + 1. Install Vagrant on your local machine. Install one of the current + providers supported: VirtualBox, Libvirt or Vagrant + 2. Git clone the astara repository. + 3. Run `cd vagrant` + 4. Run `vagrant up` + It will take from 10 to 60 minutes, depending on your internet speed. + Vagrant-cachier can speed up the process [1]. + 5. `vagrant ssh` + You will get a VM with everything running. + You will get vm shell with keystone and neutron already running. + +At this point you should have astara running inside of the Vagrant VM. + +[1] http://fgrehm.viewdocs.io/vagrant-cachier/ + +Vagrant Options available +------------------------- + +You can set the following environment variables before running `vagrant up` to modify +the definition of the Virtual Machine spawned: + + * **VAGRANT\_ASTARA\_VM\_BOX**: To change the Vagrant Box used. Should be available in + [atlas](http://atlas.hashicorp.com). + + export VAGRANT_ASTARA_VM_BOX=centos/7 + + Could be an example of a rpm-based option. + + * **VAGRANT\_ASTARA\_VM\_MEMORY**: To modify the RAM of the VM. Defaulted to: 4096 + * **VAGRANT\_ASTARA\_VM\_CPU**: To modify the cpus of the VM. Defaulted to: 2 + * **VAGRANT\_ASTARA\_RUN\_DEVSTACK**: Whether `vagrant up` should run devstack to + have an environment ready to use. Set it to 'false' if you want to edit + `local.conf` before run ./stack.sh manually in the VM. Defaulted to: true. + See below for additional options for editing local.conf. + +Additional devstack configuration +--------------------------------- + +To add additional configuration to local.conf before the VM is provisioned, you can +create a file called "user_local.conf" in the vagrant directory of astara. This file +will be appended to the "local.conf" created during the Vagrant provisioning. + +For example, to use OVN as the Neutron plugin with Astara, you can create a +"user_local.conf" with the following configuration: + + enable_plugin networking-ovn http://git.openstack.org/openstack/networking-ovn + enable_service ovn-northd + enable_service ovn-controller + disable_service q-agt + disable_service q-l3 diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile new file mode 100644 index 00000000..b8eb203d --- /dev/null +++ b/vagrant/Vagrantfile @@ -0,0 +1,47 @@ +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + VM_MEMORY = ENV.fetch('VAGRANT_ASTARA_VM_MEMORY', 6144) + VM_CPUS = ENV.fetch('VAGRANT_ASTARA_VM_CPUS', 2) + RUN_DEVSTACK = ENV.fetch('VAGRANT_ASTARA_RUN_DEVSTACK', 'true') + + config.vm.hostname = 'devstack' + + config.vm.provider 'virtualbox' do |v, override| + override.vm.box = ENV.fetch('VAGRANT_ASTARA_VM_BOX', 'ubuntu/trusty64') + v.memory = VM_MEMORY + v.cpus = VM_CPUS + end + + config.vm.provider 'parallels' do |v, override| + override.vm.box = ENV.fetch('VAGRANT_ASTARA_VM_BOX', 'boxcutter/ubuntu1404') + v.memory = VM_MEMORY + v.cpus = VM_CPUS + v.customize ['set', :id, '--nested-virt', 'on'] + end + + config.vm.provider 'libvirt' do |v, override| + override.vm.box = ENV.fetch('VAGRANT_ASTARA_VM_BOX', 'celebdor/trusty64') + v.memory = VM_MEMORY + v.cpus = VM_CPUS + v.nested = true + v.graphics_type = 'spice' + v.video_type = 'qxl' + end + + config.vm.synced_folder '../devstack/', '/devstack' + # For CentOS machines it needs to be specified + config.vm.synced_folder '.', '/vagrant' + + config.vm.provision :shell do |s| + s.path = 'vagrant.sh' + s.args = RUN_DEVSTACK + end + + if Vagrant.has_plugin?('vagrant-cachier') + config.cache.scope = :box + end + + config.vm.network :forwarded_port, guest: 80, host_ip: "127.0.0.1", host: 8080 +end diff --git a/vagrant/devstack.sh b/vagrant/devstack.sh new file mode 100755 index 00000000..5e3e37eb --- /dev/null +++ b/vagrant/devstack.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +BASHPATH=$(dirname "$0"\") +RUN_DEVSTACK="$1" +echo "Run script from $BASHPATH" + +# Copied shamelessly from Devstack +function GetOSVersion { + if [[ -x $(which lsb_release 2>/dev/null) ]]; then + os_FAMILY='Debian' + elif [[ -r /etc/redhat-release ]]; then + os_FAMILY='RedHat' + else + echo "Unsupported distribution!" + exit 1; + fi +} + +GetOSVersion + +if [[ "$os_FAMILY" == "Debian" ]]; then + export DEBIAN_FRONTEND noninteractive + sudo apt-get update + sudo apt-get install -qqy git +elif [[ "$os_FAMILY" == "RedHat" ]]; then + sudo yum install -y -d 0 -e 0 git +fi + +# determine checkout folder +PWD=$(su "$OS_USER" -c "cd && pwd") +DEVSTACK=$PWD/devstack + +# check if devstack is already there +if [[ ! -d "$DEVSTACK" ]] +then + echo "Download devstack into $DEVSTACK" + + # clone devstack + su "$OS_USER" -c "cd && git clone -b master https://github.com/openstack-dev/devstack.git $DEVSTACK" + + echo "Copy configuration" + + # copy local.conf.sample settings (source: astara/devstack/local.conf.sample) + cp /devstack/local.conf.sample $DEVSTACK/local.conf + # If local settings are present, append them + if [ -f "/vagrant/user_local.conf" ]; then + cat /vagrant/user_local.conf >> $DEVSTACK/local.conf + fi + chown "$OS_USER":"$OS_USER" "$DEVSTACK"/local.conf + +fi + +if $RUN_DEVSTACK; then + echo "Start Devstack" + su "$OS_USER" -c "cd $DEVSTACK && ./stack.sh" +else + echo "Virtual Machine ready. You can run devstack by executing '/home/vagrant/devstack/stack.sh'" +fi diff --git a/vagrant/vagrant.sh b/vagrant/vagrant.sh new file mode 100755 index 00000000..8b14c75f --- /dev/null +++ b/vagrant/vagrant.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +export OS_USER=vagrant +export OS_HOST_IP=172.68.5.10 + +# run script +bash /vagrant/devstack.sh "$1"