alshabib
Committed by Gerrit Code Review

Vagrant box for development use.

vagrant up onosdev sets up a vm with three lxc instances
which should be used with the lxc cell.

Change-Id: I18b5cc5366efc61f05063798b498559eb49a8eff
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
config.vm.synced_folder ".", "/vagrant", mount_options: ["dmode=700,fmode=600"]
else
config.vm.synced_folder ".", "/vagrant"
end
config.vm.define "onosdev" do |d|
d.vm.box = "ubuntu/trusty64"
d.vm.hostname = "onosdev"
d.vm.network "private_network", ip: "10.100.198.200"
d.vm.provision :shell, path: "scripts/bootstrap_ansible.sh"
d.vm.provision :shell, inline: "PYTHONUNBUFFERED=1 ansible-playbook /vagrant/ansible/onosdev.yml -c local"
d.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
v.memory = 8192
v.cpus = 2
end
end
end
[defaults]
callback_plugins=/etc/ansible/callback_plugins/
host_key_checking=False
deprecation_warnings=False
[privilege_escalation]
become=True
become_method=sudo
become_user=root
- hosts: localhost
remote_user: vagrant
serial: 1
roles:
- common
- brctl
- java8-oracle
- lxc
- name: Bridge onosbr0 is present
become: yes
template:
src: templates/create_bridge.j2
dest: /etc/network/if-pre-up.d/create_bridge_{{ networks.bridge_name }}
owner: root
group: root
mode: 0755
- name: eth1 is in onosbr0
become: yes
template:
src: templates/add_iface.j2
dest: /etc/network/if-pre-up.d/add_iface_{{ interfaces.hostonly }}
owner: root
group: root
mode: 0755
- name: Activate onos bridge
become: yes
command: /etc/network/if-pre-up.d/create_bridge_{{ networks.bridge_name }} report-changed
register: bridge_changed
changed_when: bridge_changed.stdout == 'true'
- name: Activate eth1 in bridge
become: yes
command: /etc/network/if-pre-up.d/add_iface_{{ interfaces.hostonly }} report-changed
register: bridge_iface_changed
changed_when: bridge_iface_changed == 'true'
- name: Flush ip of eth1
become: yes
command: /sbin/ip addr flush {{ interfaces.hostonly }}
- name: bring onosbr0 up
become: yes
command: /sbin/ifconfig onosbr0 up
#!/bin/bash
REPORT_CHANGED=0
if [ $# -gt 0 ]; then
REPORT_CHANGED=1
fi
CHANGED='false'
FOUND=$(brctl show | grep "^{{ interfaces.hostonly }}" | wc -l)
if [ $FOUND -eq 0 ]; then
CHANGED='true'
brctl addif {{ networks.bridge_name }} {{ interfaces.hostonly }}
fi
if [ $REPORT_CHANGED -ne 0 ]; then
echo -n $CHANGED
fi
#!/bin/bash
REPORT_CHANGED=0
if [ $# -gt 0 ]; then
REPORT_CHANGED=1
fi
CHANGED='false'
FOUND=$(brctl show | grep "^{{ networks.bridge_name }}" | wc -l)
if [ $FOUND -eq 0 ]; then
CHANGED='true'
brctl addbr {{ networks.bridge_name }}
fi
if [ $REPORT_CHANGED -ne 0 ]; then
echo -n $CHANGED
fi
interfaces:
hostonly: "{{ hostonly_iface | default('eth1') }}"
networks:
# CHANGE:
# 'bridge' name of the bridge to create that is used when connecting
# the LXC containers
bridge_name: "{{ bridge_name | default('onosbr0') }}"
bridge: "{{ bridge_network | default('10.100.198.200/24') }}"
hosts: [
{ host_ip: "10.100.198.200", host_name: "onosdev"},
{ host_ip: "10.100.198.201", host_name: "onos1"},
{ host_ip: "10.100.198.202", host_name: "onos2"},
{ host_ip: "10.100.198.203", host_name: "onos3"},
]
- name: bridge-utils is present
apt:
name: bridge-utils
force: yes
tags: [common]
- name: lxc is present
apt:
name: lxc
force: yes
tags: [common]
- name: python-dev is present
apt:
name: python-dev
force: yes
tags: [common]
- name: lxc-dev is present
apt:
name: lxc-dev
force: yes
tags: [common]
- name: python-pip is present
apt:
name: python-pip
force: yes
tags: [common]
- name: python3-lxc is present
pip:
name: lxc-python2
state: present
tags: [common]
- name: Host is present
lineinfile:
dest: /etc/hosts
regexp: "^{{ item.host_ip }}"
line: "{{ item.host_ip }} {{ item.host_name }}"
with_items: hosts
tags: [common]
---
galaxy_info:
author: Ciena Blueplanet
description: Java 8 from Oracle
company: Ciena Blueplanet
license: Apache 2.0
min_ansible_version: 2.0
platforms:
- name: Ubuntu
versions:
- trusty
galaxy_tags:
- development
- system
dependencies: []
---
- name: Install add-apt-repostory
become: yes
apt: name=software-properties-common state=latest update_cache=yes
- name: Add Oracle Java Repository
become: yes
apt_repository: repo='ppa:webupd8team/java'
- name: Accept Java 8 License
become: yes
debconf: name='oracle-java8-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'
- name: Install Oracle Java 8
become: yes
apt: name={{item}} state=latest
with_items:
- oracle-java8-installer
- ca-certificates
- oracle-java8-set-default
lxc.mount.entry = /usr/lib/jvm/java-8-oracle usr/lib/jvm/java none bind,create=dir 0 0
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.name = eth0
lxc.network.type = veth
lxc.network.link = onosbr0
lxc.network.flags = up
lxc.network.name = eth1
- name: Remove lxc default config
become: yes
file: path=/etc/lxc/default.conf state=absent
- name: Copy default lxc file
become: yes
copy:
src: files/default.conf
dest: /etc/lxc/default.conf
mode: 644
- name: Create onos1 container
lxc_container:
name: onos1
container_log: true
template: ubuntu
state: started
template_options: --release trusty
container_config:
- "lxc.network.ipv4=10.100.198.201/24"
container_command: |
ln -s /usr/lib/jvm/java/bin/java /usr/bin/java
apt-get update
apt-get install -y openssh-server
echo "ubuntu ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-onos-sudoers
- name: Create onos2 container
lxc_container:
name: onos2
container_log: true
template: ubuntu
state: started
template_options: --release trusty
container_config:
- "lxc.network.ipv4=10.100.198.202/24"
container_command: |
ln -s /usr/lib/jvm/java/bin/java /usr/bin/java
apt-get update
apt-get install -y openssh-server
echo "ubuntu ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-onos-sudoers
- name: Create onos3 container
lxc_container:
name: onos3
container_log: true
template: ubuntu
state: started
template_options: --release trusty
container_config:
- "lxc.network.ipv4=10.100.198.203/24"
container_command: |
ln -s /usr/lib/jvm/java/bin/java /usr/bin/java
apt-get update
apt-get install -y openssh-server
echo "ubuntu ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-onos-sudoers
#!/bin/bash
#
# Copyright 2012 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
echo "Installing Ansible..."
apt-get install -y software-properties-common ca-certificates
apt-add-repository ppa:ansible/ansible
apt-get update
apt-get install -y ansible
cp /vagrant/ansible/ansible.cfg /etc/ansible/ansible.cfg
export OCI=10.100.198.201
export OC1=10.100.198.201
export OC2=10.100.198.202
export OC3=10.100.198.203
export ONOS_APPS=drivers,openflow,proxyarp
export ONOS_NIC=10.100.198.*
export ONOS_SCENARIOS=$HOME/work/onos-next/tools/test/scenarios
export ONOS_USER=ubuntu
export ONOS_GROUP=ubuntu
export ONOS_WEB_PASS=rocks
export ONOS_WEB_USER=onos