summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/onos_cluster
diff options
context:
space:
mode:
authorchenshuai@huawei.com <chenshuai@huawei.com>2015-09-20 12:45:08 +0800
committerchenshuai@huawei.com <chenshuai@huawei.com>2015-09-20 12:46:50 +0800
commitab9c9cbd1c96611c5cbe56260a73524186bf72f1 (patch)
tree6510d4c72133a0f5ea1681e58650538995bcee7e /deploy/adapters/ansible/roles/onos_cluster
parentfb0d6fc92a6286953e0985a68d317cd108cf8d4b (diff)
Write ONOS ansible script for Ubuntu14.04
JIRA: COMPASS-54 Change-Id: Icb0f0023681a0407bb987757171f72d70c1360f6 Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/onos_cluster')
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/files/install_jdk8.tarbin0 -> 4608 bytes
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/files/networking-onos.tarbin0 -> 20480 bytes
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/handlers/main.yml3
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/tasks/main.yml11
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/tasks/onos_controller.yml145
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/tasks/openvswitch.yml34
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/templates/cluster.json10
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/templates/ml2_conf.sh7
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/templates/tablets.json63
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/vars/Debian.yml6
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/vars/RedHat.yml6
-rwxr-xr-xdeploy/adapters/ansible/roles/onos_cluster/vars/main.yml6
12 files changed, 291 insertions, 0 deletions
diff --git a/deploy/adapters/ansible/roles/onos_cluster/files/install_jdk8.tar b/deploy/adapters/ansible/roles/onos_cluster/files/install_jdk8.tar
new file mode 100755
index 00000000..faaaeb39
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/files/install_jdk8.tar
Binary files differ
diff --git a/deploy/adapters/ansible/roles/onos_cluster/files/networking-onos.tar b/deploy/adapters/ansible/roles/onos_cluster/files/networking-onos.tar
new file mode 100755
index 00000000..765afa02
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/files/networking-onos.tar
Binary files differ
diff --git a/deploy/adapters/ansible/roles/onos_cluster/handlers/main.yml b/deploy/adapters/ansible/roles/onos_cluster/handlers/main.yml
new file mode 100755
index 00000000..c8742dd5
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/handlers/main.yml
@@ -0,0 +1,3 @@
+---
+- name: restart onos service
+ service: name=onos state=restarted enabled=yes
diff --git a/deploy/adapters/ansible/roles/onos_cluster/tasks/main.yml b/deploy/adapters/ansible/roles/onos_cluster/tasks/main.yml
new file mode 100755
index 00000000..c3e7c7b7
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/tasks/main.yml
@@ -0,0 +1,11 @@
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Install ONOS Cluster on Controller
+ include: onos_controller.yml
+ when: inventory_hostname in groups['onos']
+
+- name: Install ONOS Cluster on Compute
+ include: openvswitch.yml
+ when: groups['onos']|length !=0 and inventory_hostname not in groups['onos']
+
diff --git a/deploy/adapters/ansible/roles/onos_cluster/tasks/onos_controller.yml b/deploy/adapters/ansible/roles/onos_cluster/tasks/onos_controller.yml
new file mode 100755
index 00000000..20691cc9
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/tasks/onos_controller.yml
@@ -0,0 +1,145 @@
+---
+- name: upload onos driver package
+ unarchive: src=networking-onos.tar dest=/opt/
+
+- name: install onos driver
+ command: su -s /bin/sh -c "/opt/networking-onos/install_driver.sh"
+
+- name: install onos required packages
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+ with_items: packages
+
+- name: get image http server
+ shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
+ register: http_server
+
+- name: download oracle-jdk8 package file
+ get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/onos/{{ jdk8_pkg_name }}" dest=/opt/{{ jdk8_pkg_name }}
+
+- name: upload install_jdk8 scripts
+ unarchive: src=install_jdk8.tar dest=/opt/
+
+- name: install install_jdk8 package
+ command: su -s /bin/sh -c "/opt/install_jdk8/install_jdk8.sh"
+
+- name: create JAVA_HOME environment variable
+ shell: >
+ export J2SDKDIR=/usr/lib/jvm/java-8-oracle;
+ export J2REDIR=/usr/lib/jvm/java-8-oracle/jre;
+ export PATH=$PATH:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin;
+ export JAVA_HOME=/usr/lib/jvm/java-8-oracle;
+ export DERBY_HOME=/usr/lib/jvm/java-8-oracle/db;
+
+- name: create onos group
+ group: name=onos system=yes state=present
+
+- name: create onos user
+ user:
+ name: onos
+ group: onos
+ home: "{{ onos_home }}"
+ createhome: "yes"
+ system: "yes"
+ shell: "/bin/false"
+
+- name: download onos package
+ get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/onos/{{ onos_pkg_name }}" dest=/opt/{{ onos_pkg_name }}
+
+- name: create new jar repository
+ command: su -s /bin/sh -c "mkdir ~/.m2"
+
+- name: download jar repository
+ get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/onos/repository.tar" dest=~/.m2/
+
+- name: extract jar repository
+ command: su -s /bin/sh -c "tar xvf ~/.m2/repository.tar -C ~/.m2/"
+
+- name: extract onos package
+ command: su -s /bin/sh -c "tar xzf /opt/{{ onos_pkg_name }} -C {{ onos_home }} --strip-components 1 --no-overwrite-dir -k --skip-old-files" onos
+
+- name: configure onos service
+ shell: >
+ echo 'export ONOS_OPTS=debug' > {{ onos_home }}/options;
+ echo 'export ONOS_USER=root' >> {{ onos_home }}/options;
+ mkdir {{ onos_home }}/var;
+ mkdir {{ onos_home }}/config;
+ sed -i '/pre-stop/i\env JAVA_HOME=/usr/lib/jvm/java-8-oracle' {{ onos_home }}/debian/onos.conf;
+ cp -rf {{ onos_home }}/debian/onos.conf /etc/init/;
+ cp -rf {{ onos_home }}/debian/onos.conf /etc/init.d/;
+# notify:
+# - restart onos service
+
+- name: configure onos boot feature
+ shell: >
+ sed -i '/^featuresBoot=/c\featuresBoot={{ onos_boot_features }}' {{ onos_home }}/{{ karaf_dist }}/etc/org.apache.karaf.features.cfg;
+
+- name: create cluster json
+ template:
+ src: cluster.json
+ dest: "{{ onos_home }}/config/cluster.json"
+# notify:
+# - restart onos service
+
+- name: create tablets json
+ template:
+ src: tablets.json
+ dest: "{{ onos_home }}/config/tablets.json"
+# notify:
+# - restart onos service
+
+- name: wait for config time
+ shell: "sleep 10"
+
+- name: start onos service
+ service: name=onos state=started enabled=yes
+
+- name: wait for restart time
+ shell: "sleep 60"
+
+- name: start onos service
+ service: name=onos state=restarted enabled=yes
+
+- name: wait for onos start time
+ shell: "sleep 60"
+
+- name: start onos service
+ service: name=onos state=restarted enabled=yes
+
+- name: wait for onos start time
+ shell: "sleep 100"
+
+- name: add onos auto start
+ shell: >
+ echo "onos">>/opt/service
+
+##########################################################################################################
+################################ ONOS connect with OpenStack ################################
+##########################################################################################################
+- name: Run OpenVSwitch Script
+ include: openvswitch.yml
+
+- name: Configure Neutron1
+ shell: >
+ crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers onos;
+ crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan;
+ crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers vxlan
+
+- name: Create ML2 Configuration File
+ template:
+ src: ml2_conf.sh
+ dest: "/opt/ml2_conf.sh"
+ mode: 0777
+
+- name: Configure Neutron2
+ command: su -s /bin/sh -c "/opt/ml2_conf.sh;"
+
+
+- name: Configure Neutron3
+ shell: >
+ mysql -e "drop database if exists neutron_ml2;";
+ mysql -e "create database neutron_ml2 character set utf8;";
+ mysql -e "grant all on neutron_ml2.* to 'neutron'@'%';";
+ su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron;
+
+- name: Restart neutron-server
+ service: name=neutron-server state=restarted
diff --git a/deploy/adapters/ansible/roles/onos_cluster/tasks/openvswitch.yml b/deploy/adapters/ansible/roles/onos_cluster/tasks/openvswitch.yml
new file mode 100755
index 00000000..7658d90d
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/tasks/openvswitch.yml
@@ -0,0 +1,34 @@
+---
+- name: remove neutron-plugin-openvswitch-agent auto start
+ shell: >
+ update-rc.d neutron-plugin-openvswitch-agent remove;
+ sed -i /neutron-plugin-openvswitch-agent/d /opt/service
+
+- name: shut down and disable Neutron's agent services
+ service: name=neutron-plugin-openvswitch-agent state=stopped
+
+- name: Stop the Open vSwitch service and clear existing OVSDB
+ shell: >
+ service openvswitch-switch stop ;
+ rm -rf /var/log/openvswitch/* ;
+ rm -rf /etc/openvswitch/conf.db ;
+ service openvswitch-switch start ;
+
+#- name: get image http server
+# shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
+# register: http_server
+#
+#- name: download ovs
+# get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/onos/openvswitch.tar" dest=/opt/openvswitch.tar
+#
+#- name: extract ovs
+# command: su -s /bin/sh -c "tar xvf /opt/openvswitch.tar -C /opt/"
+#
+#- name: update ovs
+# shell: >
+# cd /opt/openvswitch;
+# dpkg -i openvswitch-common_2.3.0-1_amd64.deb;
+# dpkg -i openvswitch-switch_2.3.0-1_amd64.deb;
+- name: Set ONOS as the manager
+ command: su -s /bin/sh -c "ovs-vsctl set-manager tcp:{{ ip_settings[groups['onos'][0]]['mgmt']['ip'] }}:6640;"
+
diff --git a/deploy/adapters/ansible/roles/onos_cluster/templates/cluster.json b/deploy/adapters/ansible/roles/onos_cluster/templates/cluster.json
new file mode 100755
index 00000000..5982c434
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/templates/cluster.json
@@ -0,0 +1,10 @@
+{ "ipPrefix": "{{ ip_settings[groups['onos'][0]]['mgmt']['cidr'] }}",
+ "nodes":[
+{% for host in groups['onos'] %}
+ {% if loop.last %}
+ { "id": "{{ ip_settings[host]['mgmt']['ip'] }}", "ip": "{{ ip_settings[host]['mgmt']['ip'] }}", "tcpPort": 9876 }
+ {% else %}
+ { "id": "{{ ip_settings[host]['mgmt']['ip'] }}", "ip": "{{ ip_settings[host]['mgmt']['ip'] }}", "tcpPort": 9876 },
+ {% endif %}
+{% endfor %}
+]}
diff --git a/deploy/adapters/ansible/roles/onos_cluster/templates/ml2_conf.sh b/deploy/adapters/ansible/roles/onos_cluster/templates/ml2_conf.sh
new file mode 100755
index 00000000..8ec9ae11
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/templates/ml2_conf.sh
@@ -0,0 +1,7 @@
+cat <<EOT>> /etc/neutron/plugins/ml2/ml2_conf.ini
+[ml2_onos]
+password = admin
+username = admin
+url_path = http://{{ ip_settings[groups['onos'][0]]['mgmt']['ip'] }}:8181/onos/vtn
+EOT
+
diff --git a/deploy/adapters/ansible/roles/onos_cluster/templates/tablets.json b/deploy/adapters/ansible/roles/onos_cluster/templates/tablets.json
new file mode 100755
index 00000000..f71be71f
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/templates/tablets.json
@@ -0,0 +1,63 @@
+{
+ "nodes": [
+{% for host in groups['onos'] %}
+ {% if loop.last %}
+ {
+ "ip": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "id": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "tcpPort": 9876
+ }
+ {% else %}
+ {
+ "ip": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "id": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "tcpPort": 9876
+ },
+ {% endif %}
+{% endfor %}
+ ],
+ "partitions": {
+ {% set key = 1 %}
+ {% for host in groups['onos'] %}
+ {% if loop.last %}
+ "p{{ key }}":[
+ {% for host in groups['onos'] %}
+ {% if loop.last %}
+ {
+ "ip": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "id": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "tcpPort": 9876
+ }
+ {% else %}
+ {
+ "ip": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "id": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "tcpPort": 9876
+ },
+ {% endif %}
+ {% endfor %}
+ ]
+ {% set key = key + 1 %}
+ {% else %}
+ "p{{ key }}":[
+ {% for host in groups['onos'] %}
+ {% if loop.last %}
+ {
+ "ip": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "id": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "tcpPort": 9876
+ }
+ {% else %}
+ {
+ "ip": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "id": "{{ ip_settings[host]['mgmt']['ip'] }}",
+ "tcpPort": 9876
+ },
+ {% endif %}
+ {% endfor %}
+ ],
+ {% set key = key + 1 %}
+ {% endif %}
+ {% endfor %}
+}
+}
diff --git a/deploy/adapters/ansible/roles/onos_cluster/vars/Debian.yml b/deploy/adapters/ansible/roles/onos_cluster/vars/Debian.yml
new file mode 100755
index 00000000..70ce4ef2
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/vars/Debian.yml
@@ -0,0 +1,6 @@
+---
+packages:
+ - software-properties-common
+ - crudini
+
+services: []
diff --git a/deploy/adapters/ansible/roles/onos_cluster/vars/RedHat.yml b/deploy/adapters/ansible/roles/onos_cluster/vars/RedHat.yml
new file mode 100755
index 00000000..70ce4ef2
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/vars/RedHat.yml
@@ -0,0 +1,6 @@
+---
+packages:
+ - software-properties-common
+ - crudini
+
+services: []
diff --git a/deploy/adapters/ansible/roles/onos_cluster/vars/main.yml b/deploy/adapters/ansible/roles/onos_cluster/vars/main.yml
new file mode 100755
index 00000000..66d81353
--- /dev/null
+++ b/deploy/adapters/ansible/roles/onos_cluster/vars/main.yml
@@ -0,0 +1,6 @@
+onos_pkg_url: http://downloads.onosproject.org/release/onos-1.3.0.tar.gz
+onos_pkg_name: onos-1.3.0.tar.gz
+onos_home: /opt/onos/
+karaf_dist: apache-karaf-3.0.3
+jdk8_pkg_name: jdk-8u51-linux-x64.tar.gz
+onos_boot_features: config,standard,region,package,kar,ssh,management,webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui,onos-openflow,onos-ovsdatabase,onos-app-vtnrsc,onos-app-vtn,onos-app-vtnweb,onos-app-proxyarp