Giter Club home page Giter Club logo

devstack-vm's Introduction

Neutron-enabled DevStack in a Vagrant VM with Ansible

This repository contains a Vagrantfile and an accompanying Ansible playbook that sets up a VirtualBox virtual machine that installs DevStack.

You'll also be able to ssh directly from your laptop into the VMs without needing to the ssh into the Vagrant box first.

Ansible generates a local.conf file that defaults to:

  • Use Neutron for networking
  • Disable security groups
  • No Application Catalog

You can enable Swift, Heat, Application Catalog and security groups by editing the devstack.yml file.

This project was inspired by Brian Waldon's vagrant_devstack repository.

Memory usage

By default, the VM uses 6GB of RAM and 2 cpus. If you want to change this, edit the following lines in Vagrantfile:

    vb.customize ["modifyvm", :id, "--memory", 6144]
    vb.customize ["modifyvm", :id, "--cpus", 2]

Prereqs

Install the following applications on your local machine first:

If you want to try out the OpenStack command-line tools once DevStack is running, you'll also need to install the following Python packages:

  • python-novaclient
  • python-neutronclient
  • python-openstackclient

The easiest way to install Ansible and the Python packages are with pip:

sudo pip install -r requirements.txt

Boot the virtual machine and install DevStack

Grab this repo and do a vagrant up, like so:

git clone https://github.com/lorin/devstack-vm
cd devstack-vm
vagrant up

The vagrant up command will:

  1. Download an Ubuntu 14.04 (trusty) vagrant box if it hasn't previously been downloaded to your machine.
  2. Boot the virtual machine (VM).
  3. Clone the DevStack git repository inside of the VM.
  4. Run DevStack inside of the VM.
  5. Add eth2 to the br-ex bridge inside of the VM to enable floating IP access from the host machine.

It will take at least ten minutes for this to run, and possibly much longer depending on your internet connection and whether it needs to download the Ubuntu vagrant box.

Troubleshooting

Fails to connect

You may ocassionally see the following error message:

[default] Waiting for VM to boot. This can take a few minutes.
[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.

If you see this, retry by doing:

vagrant destroy --force && vagrant up

Logging in the virtual machine

The VM is accessible at 192.168.27.100

You can type vagrant ssh to start an ssh session.

Note that you do not need to be logged in to the VM to run commands against the OpenStack endpoint.

Loading OpenStack credentials

From your local machine, to run as the demo user:

source demo.openrc

To run as the admin user:

source admin.openrc

Horizon

Initial networking configuration

Network topology

DevStack configures an internal network ("private") and an external network ("public"), with a router ("router1") connecting the two together. The router is configured to use its interface on the "public" network as the gateway.

$ openstack network list
+--------------------------------------+---------+------------------------------------------------------------------------+
| ID                                   | Name    | Subnets                                                                |
+--------------------------------------+---------+------------------------------------------------------------------------+
| 3d910901-12a0-4997-8335-948c66e1ab46 | public  | 1c458c90-3bd3-45b1-a9bf-6ed8cd56e128,                                  |
|                                      |         | 94f2f87c-c8a4-48e5-a27c-752e7be14988                                   |
| c83dc6a9-615e-4a42-b462-b5d9871a923f | private | 6e58ab8b-bc1a-4ae8-9233-f2d69a5c1821,                                  |
|                                      |         | 830a36ce-4bb4-4266-8411-5d4447e8e2e3                                   |
+--------------------------------------+---------+------------------------------------------------------------------------+

$ neutron router-list
+--------------------------------------+---------+------------------------------------------------------------------------+
| id                                   | name    | external_gateway_info                                                  |
+--------------------------------------+---------+------------------------------------------------------------------------+
| c182627f-2c78-4f0e-aa14-f740aa7a02d3 | router1 | {"network_id": "3d910901-12a0-4997-8335-948c66e1ab46",                 |
|                                      |         | "external_fixed_ips": [{"ip_address": "172.24.4.2", "subnet_id":       |
|                                      |         | "1c458c90-3bd3-45b1-a9bf-6ed8cd56e128"}, {"ip_address": "2001:db8::1", |
|                                      |         | "subnet_id": "94f2f87c-c8a4-48e5-a27c-752e7be14988"}], "enable_snat":  |
|                                      |         | true}                                                                  |
+--------------------------------------+---------+------------------------------------------------------------------------+

Add ssh and ping to the default security group

openstack security group rule create default --proto tcp --dst-port 22
openstack security group rule create default --proto icmp

Launch a cirros instance and attach a floating IP.

Source the credentials of the "demo" user and boot an instance.

source demo.openrc
nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
nova boot --flavor m1.tiny --image cirros-0.3.4-x86_64-uec --key-name mykey cirros

Once the instance has booted, get its ID.

$ nova list

+--------------------------------------+--------+--------+------------+-------------+------------------------------------------------------+
| ID                                   | Name   | Status | Task State | Power State | Networks                                             |
+--------------------------------------+--------+--------+------------+-------------+------------------------------------------------------+
| 62cf0635-aa9e-4223-bbcd-3808966959c1 | cirros | ACTIVE | -          | Running     | private=fdbc:59ac:894:0:f816:3eff:fefe:221, 10.0.0.3 |
+--------------------------------------+--------+--------+------------+-------------+------------------------------------------------------+

Use the instance ID to get its neutron port :

$ neutron port-list -c id --device_id b24fc4ad-2d66-4f28-928b-f1cf78075d33

+--------------------------------------+
| id                                   |
+--------------------------------------+
| 02491b08-919e-4582-9eb7-f8119c03b8f9 |
+--------------------------------------+

Use the neutron port ID to create an attach a floating IP to the "public"" network:

$ neutron floatingip-create public --port-id 02491b08-919e-4582-9eb7-f8119c03b8f9

Created a new floatingip:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| fixed_ip_address    | 10.0.0.3                             |
| floating_ip_address | 172.24.4.227                         |
| floating_network_id | 5770a693-cfc7-431d-ae29-76f36a2e63c0 |
| id                  | 480524e1-a5b3-491f-a6ee-9356fc52f81d |
| port_id             | 02491b08-919e-4582-9eb7-f8119c03b8f9 |
| router_id           | 0deb0811-78b0-415c-9464-f05d278e9e3d |
| tenant_id           | 512e45b937a149d283718ffcfc36b8c7     |
+---------------------+--------------------------------------+

Finally, access your instance:

Python bindings example

The included boot-cirros.py file illustrates how to execute all of the above commands using the Python bindings.

Allow VMs to connect out to the Internet

By default, VMs started by OpenStack will not be able to connect to the internet. For this to work, your host machine must be configured to do NAT (Network Address Translation) for the VMs.

On Mac OS X

Enable IP forwarding

Turn on IP forwarding if it isn't on yet:

sudo sysctl -w net.inet.ip.forwarding=1

Note that you have to do this each time you reboot.

Edit the pfctl config file to NAT the floating IP subnet

Edit /etc/pf.conf as root, and add the following line after the "net-anchor" line:

nat on en0 from 172.24.4.1/24 -> (en0)

Load the file and enable PF

sudo pfctl -f /etc/pf.conf
sudo pfctl -e

(From Martin Nash's blog. See info there on how to make the IP forwarding persist across reboots ).

On Linux

To enable NAT, issue the following commands in your host, as root:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Troubleshooting

Logs are in /opt/stack/logs

Instance immediately goes into error state

Check the nova-conductor log and search for ERROR

vagrant ssh
less -R /opt/stack/logs/n-cond.log

For example, if it's failing because there isn't enough free memory in the virtual machine, you'll see an error like this:

2016-08-01 05:42:50.237 ERROR nova.scheduler.utils [req-581add06-ba33-4b5d-9a1b-af7c74f3ce86 demo demo] [instance: 70713d2f-96fa-4ee7-a73a-4e019b78b1f9] Error from last host: vagrant-ubuntu-trusty-64 (node vagrant-ubuntu-trusty-64): [u'Traceback (most recent call last):\n', u'  File "/opt/stack/nova/nova/compute/manager.py", line 1926, in _do_build_and_run_instance\n    filter_properties)\n', u'  File "/opt/stack/nova/nova/compute/manager.py", line 2116, in _build_and_run_instance\n    instance_uuid=instance.uuid, reason=six.text_type(e))\n', u"RescheduledException: Build of instance 70713d2f-96fa-4ee7-a73a-4e019b78b1f9 was re-scheduled: internal error: process exited while connecting to monitor: Cannot set up guest memory 'pc.ram': Cannot allocate memory\n\n"]

devstack-vm's People

Contributors

ajmalmsali avatar askb avatar kramvan1 avatar lorin avatar marouenmechtri avatar plomakin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

devstack-vm's Issues

Upgraded to cirros-0.3.2 and ubuntu thrusty

index 7028c5c..5b0925f 100644
--- a/README.md
+++ b/README.md
@@ -173,7 +173,7 @@ Source the credentials of the "demo" user and boot an instance.

 source demo.openrc
 nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
  • nova boot --flavor m1.nano --image cirros-0.3.1-x86_64-uec --key-name mykey cirros
  • nova boot --flavor m1.tiny --image cirros-0.3.2-x86_64-uec --key-name mykey cirros

Once the instance has booted, get its ID.

diff --git a/Vagrantfile b/Vagrantfile
index cb3206b..2f7aff3 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -4,8 +4,8 @@

Vagrant.configure("2") do |config|

eth1, this will be the endpoint

config.vm.network :private_network, ip: "192.168.27.100"

eth2, this will be the OpenStack "public" network, use DevStack default

diff --git a/boot-cirros.py b/boot-cirros.py
index d385f37..1c20214 100755
--- a/boot-cirros.py
+++ b/boot-cirros.py
@@ -45,7 +45,7 @@ if not nova.keypairs.findall(name="mykey"):
print("done")

print("Booting cirros instance...", end='')
-image = nova.images.find(name="cirros-0.3.1-x86_64-uec")
+image = nova.images.find(name="cirros-0.3.2-x86_64-uec")
flavor = nova.flavors.find(name="m1.tiny")
instance = nova.servers.create(name="cirros", image=image, flavor=flavor,
key_name="mykey")
diff --git a/devstack.yaml b/devstack.yaml
index 464cbd1..29be5ca 100644
--- a/devstack.yaml
+++ b/devstack.yaml
@@ -3,7 +3,7 @@
vars:
devstack_repo: git://github.com/openstack-dev/devstack.git
public_ip: 192.168.27.100

  • version: stable/havana
  • version: stable/icehouse
    neutron: True
    swift: True
    security_groups: False
    @@ -26,7 +26,7 @@
    sudo: True

FATAL: all hosts have already failed -- aborting

I seem to hitting an issue: Ubuntu 14.04, ansible 1.5.4, Vagrant 1.7.4, Virtualbox 5.0.16

TASK: [install git] *********************************************************** 
ok: [default] => {"changed": false}

TASK: [checkout devstack] ***************************************************** 
changed: [default] => {"after": "c7656a12ec8ca6a35d4ef40c0cd62d9a2ec68079", "before": null, "changed": true}

TASK: [local.conf] ************************************************************ 
changed: [default] => {"changed": true, "dest": "/home/vagrant/devstack/local.conf", "gid": 1001, "group": "vagrant", "md5sum": "f11ece72b6fde9296f858f2ef1133b85", "mode": "0600", "owner": "vagrant", "size": 619, "src": "/home/vagrant/.ansible/tmp/ansible-tmp-1457952526.23-89947867771352/source", "state": "file", "uid": 1001}

TASK: [source openrc in profile] ********************************************** 
failed: [default] => {"failed": true, "rc": 257}
msg: Destination /home/vagrant/.profile does not exist !

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/user/devstack.retry

default                    : ok=6    changed=4    unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Creating an instance with the script `./boot-cirros.py` causes was warning for using an innerclass.

Creating an instance with the script ./boot-cirros.py causes was warning raised on using an innerclass or deprecated version of the API.

$ python ./boot-cirros.py 
/usr/local/lib/python2.7/dist-packages/novaclient/v2/client.py:110: UserWarning: 'novaclient.v2.client.Client' is not designed to be initialized directly. It is inner class of novaclient. Please, use 'novaclient.client.Client' instead. Related lp bug-report: 1493576
  _LW("'novaclient.v2.client.Client' is not designed to be "
done
Booting cirros instance...done
Creating floating ip...done
IP:172.24.4.9

libvirt-bin is missing

Hello,

It seems that you use virsh in your Vagrantfile in the provision section for removing default network but you don't push it with ansible in the box.

Maybe you can add this in devstack.yml :

name: install libvirt-bin
apt: "name=libvirt-bin update_cache=yes"
sudo: True

Thanks.

Install fails

I'm trying to follow the instructions, cloning...etc...vagrant up, but then I get:

[default] Running provisioner: ansible...

PLAY [default] ********************* 

GATHERING FACTS ********************* 
ok: [default]

TASK: [create keyring config directory] ********************* 
failed: [default] => {"failed": true}
msg: this module requires key=value arguments (['state=directory', 'dest={{',     'keyring_config_dir', '}}'])

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************* 
default                        : ok=1    changed=0    unreachable=0    failed=1    


Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

I'm running Ubuntu 13.04, Vagrant 1.3.3, Ansible 1.1.

Any ideas?

Cheers, Tobbe

id_vagrant may need to be chmod 0400 in order to allow use as an ssh identity file

Please consider setting id_vagrant to mode 0400 in order to facilitate its use as an ssh identity file.

This will prevent failures that resemble the following:

evstack | FAILED => Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the remote directory. Consider changing the remote temp path in ansible.cfg to a path rooted in "/tmp". Failed command was: mkdir -p $HOME/.ansible/tmp/ansible-1376859817.42-159871785923233 && chmod a+rx $HOME/.ansible/tmp/ansible-1376859817.42-159871785923233 && echo $HOME/.ansible/tmp/ansible-1376859817.42-159871785923233, exited with result 255

cinder segmentation fault issue

hi guys, I've an issue concerning cinder on line 458. I can't figure out the solution for this. Anyone can help ?
`
==> default: + is_service_enabled c-api
==> default: ++ set +o
==> default: ++ grep xtrace
==> default: + local 'xtrace=set -o xtrace'
==> default: + set +o xtrace
==> default: + return 0
==> default: + is_service_enabled tls-proxy
==> default: ++ grep xtrace
==> default: ++ set +o
==> default: + local 'xtrace=set -o xtrace'
==> default: + set +o xtrace
==> default: + return 1
==> default: + create_volume_types
==> default: + is_service_enabled c-api
==> default: ++ set +o
==> default: ++ grep xtrace
==> default: + local 'xtrace=set -o xtrace'
==> default: + set +o xtrace
==> default: + return 0
==> default: + [[ -n lvm:lvmdriver-1 ]]
==> default: + local be be_name be_type
==> default: + for be in '${CINDER_ENABLED_BACKENDS//,/ }'
==> default: + be_type=lvm
==> default: + be_name=lvmdriver-1
==> default: + cinder type-create lvmdriver-1
==> default: /home/vagrant/devstack/lib/cinder: line 458: 20727 Segmentation fault (core dumped) cinder type-create ${be_name}
==> default: ++ err_trap
==> default: ++ local r=139
==> default: ++ set +o xtrace
==> default: Error on exit
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

`

Thank you in advance.

VM still cannot access internet

Hi,
This is my network device:

eth0      Link encap:Ethernet  HWaddr 68:F7:28:1C:FF:96  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Interrupt:20 Memory:f0600000-f0620000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:11843 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11843 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2118377 (2.0 MiB)  TX bytes:2118377 (2.0 MiB)

vboxnet3  Link encap:Ethernet  HWaddr 0A:00:27:00:00:03  
          inet addr:192.168.27.1  Bcast:192.168.27.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:1768 (1.7 KiB)

vboxnet4  Link encap:Ethernet  HWaddr 0A:00:27:00:00:04  
          inet addr:172.24.4.1  Bcast:172.24.4.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:648 (648.0 b)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:FD:BE:C9  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

virbr1    Link encap:Ethernet  HWaddr 52:54:00:20:2A:70  
          inet addr:192.168.123.1  Bcast:192.168.123.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

wlan0     Link encap:Ethernet  HWaddr E8:B1:FC:C1:26:4F  
          inet addr:9.112.130.225  Bcast:9.112.131.255  Mask:255.255.254.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23687 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17949 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27644690 (26.3 MiB)  TX bytes:1993361 (1.9 MiB)

I have execute the command:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

but in iptables:

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535 
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535 
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535 
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24    masq ports: 1024-65535 
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    
MASQUERADE  tcp  --  192.168.123.0/24    !192.168.123.0/24    masq ports: 1024-65535 
MASQUERADE  udp  --  192.168.123.0/24    !192.168.123.0/24    masq ports: 1024-65535 
MASQUERADE  all  --  192.168.123.0/24    !192.168.123.0/24    
MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0           
MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0           
MASQUERADE  all  --  0.0.0.0/0            0.0.0.0/0   

i am not quite similar network config, could you give me some advice?

Any advise how to get access to internet from instances?

I've just installed devstack and everything look to be working fine, except one thing, I can't get access to internet from instances.
I can ssh into instance from my local machine with floating ip and i can ssh back into my local machine from instance, but i can't get access to my local network.

I'd be very grateful for any assistance.

How to correct reboot

Hi,
When i vagrant halt and vagrant up again, seems the openstack service is not running normally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.